欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android編程實(shí)現(xiàn)監(jiān)聽(tīng)EditText變化的方法

 更新時(shí)間:2015年11月12日 14:49:57   作者:jie1991liu  
這篇文章主要介紹了Android編程實(shí)現(xiàn)監(jiān)聽(tīng)EditText變化的方法,涉及Android針對(duì)EditText的相關(guān)操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了Android編程實(shí)現(xiàn)監(jiān)聽(tīng)EditText變化的方法。分享給大家供大家參考,具體如下:

監(jiān)聽(tīng)EditText中的內(nèi)容的變化。在EditText沒(méi)有找到一個(gè)setOnxxxx的方法。百度了一下,原來(lái)在EditText中有一個(gè)方法addTextChangedListner(TextWatcher watcher)方法,用他可以時(shí)時(shí)監(jiān)聽(tīng)EditText的內(nèi)容變化。TextWatcher是一個(gè)接口類,所以必須實(shí)現(xiàn)TextWatcher里的抽象方法:

當(dāng)EditText里面的內(nèi)容有變化的時(shí)候,觸發(fā)TextChangedListener事件,就會(huì)調(diào)用TextWatcher里面的抽象方法。

et_pos.addTextChangedListener(new TextWatcher() {
  @Override
  public void onTextChanged(CharSequence s, int start, int before, int count){}
  @Override
  public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
  @Override
  public void afterTextChanged(Editable s) {
    if (s.length() != 0) {
      clearPosition.setVisibility(View.VISIBLE);
    }else {
      clearPosition.setVisibility(View.INVISIBLE);
    }
  }
});

希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論