标签:
final CharSequence edit = text2.getText();
text2.setCursorVisible(true);
text2.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
int sta = 0;
int end = 0;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
sta = text2.getSelectionStart();
return true;
}
case MotionEvent.ACTION_MOVE: {
text2.setTextColor(Color.RED);
SpannableStringBuilder styled = new SpannableStringBuilder(edit);
styled.setSpan(new ForegroundColorSpan(Color.BLUE), 1,30,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
text2.setText(styled);
return true;
}
case MotionEvent.ACTION_UP: {
end = text2.getSelectionEnd();
CharSequence sel = edit.subSequence(5, 80);
text1.append(String.valueOf(end));
return true;
}
}
return true;
}
});
标签:
原文地址:http://www.cnblogs.com/lucktian/p/5520925.html