package com.sogouchat.smsmms; import com.sogouchat.search.HitTextHelper; import android.content.Context; import android.text.method.LinkMovementMethod; import android.util.AttributeSet; import android.widget.TextView; public class AutoTransTextView extends TextView { private Context context; public AutoTransTextView(Context context) { super(context); this.context = context; // TODO Auto-generated constructor stub } public AutoTransTextView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; // TODO Auto-generated constructor stub } public AutoTransTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); this.context = context; // TODO Auto-generated constructor stub } // @Override // public void setText(CharSequence text, BufferType type) { // // TODO Auto-generated method stub // super.setText(text, type); // Translate(); // } // public void Translate(){ // setText(MessageTranslate.Trans(context, getText().toString())); // } public void SetTextByMark(String str){ if (str.equals("") || str==null) { } else { setText(MessageTranslate.Trans(context, str)); //setClickable(true); setMovementMethod(LinkMovementMethod.getInstance()); } } public void SetTextByMarkAndSearchKey(String str,String strKey){ if ( str==null ||str.equals("") ) { } else { if ( strKey==null||strKey.equals("") ) { SetTextByMark(str); } else { CharSequence strText = MessageTranslate.Trans(context, HitTextHelper.GetHitText(str, strKey).toString()); setText(strText); //setClickable(true); setMovementMethod(LinkMovementMethod.getInstance()); } } } }