读书人

Android中TextView输入字数统计跟限制

发布时间: 2012-08-01 17:53:41 作者: rapoo

Android中TextView输入字数统计和限制
  ??????????????? selectionStart = content.getSelectionStart();
  ??????????????? selectionEnd = content.getSelectionEnd();
  ????????????????if (temp.length() > num) {
  ??????????????????? s.delete(selectionStart - 1, selectionEnd);
  ??????????????????? int tempSelection = selectionEnd;
  ??????????????????? content.setText(s);
  ??????????????????? content.setSelection(tempSelection);//设置光标在最后
  ??????????????? }
  ??????????? }
  ???});

读书人网 >Android

热点推荐