android EditView自动判断输入长度,并限制字数,然后将光标停在最后
2014-11-11 15:28
489 查看
<EditText android:id="@+id/myinfoedit_remark_et" android:layout_width="fill_parent" android:layout_height="120dp" android:background="@color/white" android:gravity="top" android:hint="我的签名" android:paddingLeft="15dp" android:paddingTop="15dp" android:paddingRight="15dp" android:textColor="@color/text_222222" android:textColorHint="@color/text_c4c4c4" android:textSize="14dp" />
<TextView
android:id="@+id/shufuxianzhi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#016cd9"
android:textSize="12dp" />
mRemark_Et.addTextChangedListener(new TextWatcher()
{//EditView自动判断输入长度
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s)
{
String content = mRemark_Et.getText().toString();
int l = content.length();
mRemarkXianZhi.setText(l + "");//需要将数字转成字符串
if (l > 30)
{
mRemark_Et.setText(content.substring(0, 30));
mRemark_Et.setSelection(30);//EditView设置光标到最后
}
}
});
相关文章推荐
- Android---3种方式限制EditView输入字数(转载)
- Android---3种方式限制EditView输入字数
- 修改Android EditText光标,限制EditText的输入字数
- Android---3种方式限制EditView输入字数
- Android---3种方式限制EditView输入字数
- Android---3种方式限制EditView输入字数
- 【转载】Android---3种方式限制EditView输入字数
- Android---3种方式限制EditView输入字数(转载)
- android edittext 输入长度限制并提示
- textfield、 textView内容长度限制(中文输入越界)附带:textView回车效果,判断禁止字符
- android EditText限制输入的字数
- android edittext 输入长度限制并提示
- android EditText 对输入字数和内容范围进行限制
- Android EditText输入字数限制总结(包括中文输入内存溢出的解决方法)
- android editview判断输入内容格式
- 限制textView的长度 对textView 的输入个数进行判断
- Android EditText限制输入长度
- android: EditText 输入固定位数后光标自动移动到下一EditText
- Android editText 输入字数限制
- android editText输入文本框限制输入字数和字数提示