0
我想在運行時更改編輯文本的文本,就像我在edittext中鍵入字符一樣,如果edittext lenth大於3,那麼它應該保持括號。如何在運行時在EditText中更改文本android
如果有人這樣做請讓我知道。
在此先感謝
Trapti
我想在運行時更改編輯文本的文本,就像我在edittext中鍵入字符一樣,如果edittext lenth大於3,那麼它應該保持括號。如何在運行時在EditText中更改文本android
如果有人這樣做請讓我知道。
在此先感謝
Trapti
您可以註冊,只要字符輸入或從EditText上字段中刪除那個叫的EditText一個TextWatcher:
EditText editText = (EditText) findViewById(R.id.edit_text_field_id);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// This method is called to notify you that, within s, the count characters
// beginning at start are about to be replaced by new text with length after.
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// This method is called to notify you that, within s, the count characters
// beginning at start have just replaced old text that had length before.
}
@Override
public void afterTextChanged(Editable s) {
// This method is called to notify you that, somewhere within s, the text has
// been changed.
}
});
見TextWatcher文檔瞭解更多詳情。
請說明。 「保持支架」是什麼意思? –