代码之家  ›  专栏  ›  技术社区  ›  Jim

更改ContextChanged事件中EditText内容的正确方法

  •  1
  • Jim  · 技术社区  · 15 年前

    下面的代码导致了内化循环问题(如文档所述)。 那么,如何设置EditText内容呢? 我有一个文本消息应用程序,其中edittext说“键入要撰写”,我想删除 用户开始输入消息后的说明。蒂亚

    et.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                }
               public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    
            if(et.getText().toString().equals(getString(R.string.txtMessage_type_to_compose))) {
            try {
                et.setText("");
            } catch (Exception e) {
                 Log.d(TAG,"exception : " + e.toString());
            }   
                }
      });
    
    1 回复  |  直到 15 年前
        1
  •  2
  •   Cristian    15 年前

    EditText

    <EditText
        ....
        android:hint="Type to compose"/>
    

    推荐文章