2014-09-13 51 views

回答

0

inputed你需要使用一個TextWatcher 一個TextWatcher會看你的EditText任何用戶交互使用onTextChanged的方法來檢測用戶開始鍵入這裏是如何做到這一點

myedittext.addTextChangedListener(new TextWatcher() { 
      @Override 
      public void onTextChanged(CharSequence s, int start, int before, int count) { 

       // TODO Auto-generated method stub 
       //here add your code 
       editetext2.setVisibility(View.VISIBLE); 
      } 

      @Override 
      public void beforeTextChanged(CharSequence s, int start, int count, int after) { 

       // TODO Auto-generated method stub 
      } 

      @Override 
      public void afterTextChanged(Editable s) { 

       // TODO Auto-generated method stub 
      } 
     }); 
1

您可以設置EditText比你目前的EditText和intially可見其設置爲GONE

android:visibility="gone" 

當你想展示這個新EdiText,設置

Edittext textNew=(TextView)mainView.findViewById(R.id.textNew); 

textOld.addTextChangedListener(new TextWatcher() { 

    @Override 
    public void onTextChanged(CharSequence s, int start, int before, int count) { 
     // TODO Auto-generated method stub 
     if (s.length()>=1) { 
      textNew.setVisibility(View.VISIBLE); 
     } 
    } 

    @Override 
    public void beforeTextChanged(CharSequence s, int start, int count, int after) { 
     // TODO Auto-generated method stub 
    } 

    @Override 
    public void afterTextChanged(Editable s) { 
     // TODO Auto-generated method stub 

    } 
}); 
相關問題