2017-03-01 12 views
0

編集テキストに数字が追加されたときに検出する必要があるアプリケーションを開発しています。Edittextに焦点を当てるかどうかはJavaのandroidスタジオ

どんなのEditTextが変更された場合、他の人がこれはあなたの要求のための一例だろう

etdec = (EditText)findViewById(R.id.etdec); 
    etbi = (EditText)findViewById(R.id.etbi); 
    ethex = (EditText)findViewById(R.id.ethex); 
    etOctal = (EditText)findViewById(R.id.etOct); 
+0

addTextChangedListenerを実装 – akhilesh0707

答えて

0

を無効になります。

public class Main extends AppCompatActivity implements TextWatcher { 

    private EditText etdec, etbi, ethex, etOctal; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     etdec = (EditText)findViewById(R.id.etdec); 
     etbi = (EditText)findViewById(R.id.etbi); 
     ethex = (EditText)findViewById(R.id.ethex); 
     etOctal = (EditText)findViewById(R.id.etOct); 
     if(etdec) etdec.addTextChangedListener(new TextWatcher(){ 

      @Override 
      public void beforeTextChanged(CharSequence s, int start, int count, int after) { 
       etbi.setEnabled(false); 
       ethex.setEnabled(false); 
       etOctal.setEnabled(false); 
      } 

      @Override 
      public void onTextChanged(CharSequence s, int start, int before, int count) { 
       kaufort_feld.setEnabled(false); 
      } 

      @Override 
      public void afterTextChanged(Editable s) { 

      } 
     }); 
     if(etbi) etbi.addTextChangedListener(new TextWatcher(){ 

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

      } 

      @Override 
      public void onTextChanged(CharSequence s, int start, int before, int count) { 
       etdec.setEnabled(false); 
       ethex.setEnabled(false); 
       etOctal.setEnabled(false); 
      } 

      @Override 
      public void afterTextChanged(Editable s) { 

      } 
     }); 
     if(ethex) ethex.addTextChangedListener(new TextWatcher(){ 

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

      } 

      @Override 
      public void onTextChanged(CharSequence s, int start, int before, int count) { 
       etdec.setEnabled(false); 
       etbi.setEnabled(false); 
       etOctal.setEnabled(false); 
      } 

      @Override 
      public void afterTextChanged(Editable s) { 

      } 
     }); 
     if(etOctal) etOctal.addTextChangedListener(new TextWatcher(){ 

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

      @Override 
      public void onTextChanged(CharSequence s, int start, int before, int count) { 
       etdec.setEnabled(false); 
       etbi.setEnabled(false); 
       ethex.setEnabled(false); 
      } 

      @Override 
      public void afterTextChanged(Editable s) { 

      } 
     }); 
    } 
} 
関連する問題