我正在开发一个应用程序。在xml布局中,我取了一个编辑文本,并将其设置为可绘制的背景。
现在我想要的是-我想设置提示为可绘制,也希望设置文本,如图像所示。

我试着设置提示,但当我设置提示时。没问题。但当我设置140个字符时,时间提示就会隐藏起来。
我想保留这140个字符时,也是当用户要键入。在每一个字符上,剩下的字符都会减少。
那怎么做请引导我..。
发布于 2014-09-26 13:30:18
在TextWatcher上使用EdiText,并使用TextView显示其余字符
private TextView mTextView;
private EditText mEditText;
private final TextWatcher mTextEditorWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
//This sets a textview to the current length
mTextView.setText(String.valueOf(s.length()));
}
public void afterTextChanged(Editable s) {
}
};
mEditText.addTextChangedListener(mTextEditorWatcher);发布于 2014-09-26 13:30:52
您必须在一个相对布局中接受您的EditText,这样您就可以设置一个文本视图,其值在键入单个字母时将被更改,因此您需要为此实现Textwatcher。
https://stackoverflow.com/questions/26060667
复制相似问题