Android:编辑文字提示

Man*_*gde 2 android android-ui android-layout android-edittext

我正在开发一个应用程序.在xml布局中,我正在编辑文本并将其设置为可绘制的背景.

现在我想要的是 - 我想将提示设置为可绘制,并且还想设置文本,如图所示.在此输入图像描述

我尝试设置提示但是当我设置提示时.没关系.但当我设置剩下的140个字符时,提示隐藏了.

当用户打算输入时,我想保留那140个字符.在每一个角色上,剩下的角色都会减少.

那么该怎么做请指导我......

Mil*_*ank 6

使用TextWatcherEdiText和使用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);
Run Code Online (Sandbox Code Playgroud)