OnTextChanged老是记不住,抄的作业,找地方存着而已
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
   | public class MainActivity extends AppCompatActivity {              @Nullable      @BindView(R.id.tv_text)     TextView tv_text;     @BindView(R.id.yzs)     TextView yzs;     @BindView(R.id.wzs)     TextView wzs;     @BindViews({R.id.b1 , R.id.b2 , R.id.b3})      List<Button> buttons;     @BindString(R.string.app_name)      String appname;     @BindView(value = R.id.et_edittext)     EditText edt;     @BindView(R.id.list)     ListView list;       @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);           ButterKnife.bind(this);          tv_text.setText("BindView");         for (int i= 0 ; i < buttons.size() ; i++) {             int ii = i + i;             buttons.get(i).setText("bt" + ii);         }           String [] items = {"1" , "2" , "3" , "4"};         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this , R.layout.support_simple_spinner_dropdown_item , items);         list.setAdapter(adapter);     }       @OnClick(R.id.b1)      public void bt1click(){         Toast.makeText(this, "这是点击按钮1", Toast.LENGTH_SHORT).show();     }       @OnLongClick(R.id.b2)      public boolean bt2longclick(Button bt2){         bt2.setText("这是按钮2的长按事件");         return true;     }       @OnTouch(R.id.b3)      public boolean bt3ontouch(View view , MotionEvent event) {         Toast.makeText(this, "触摸事件", Toast.LENGTH_SHORT).show();         return true;     }            @OnTextChanged(value = R.id.et_edittext , callback = OnTextChanged.Callback.BEFORE_TEXT_CHANGED)     void beforeTextChanged(CharSequence s , int start , int count , int after){         Log.i("mydate" , s.toString() + " -- " + start + " -- " + count + " -- " + after);     }       @OnTextChanged(value = R.id.et_edittext , callback = OnTextChanged.Callback.TEXT_CHANGED)     void onTextChanged(CharSequence s , int start , int before , int count) {                  yzs.setText(s.length() + "");                  int z = 50 - s.length();         wzs.setText(z + "");       }       @OnTextChanged(value = R.id.et_edittext , callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)     void afterTextChanged(Editable s){         Log.i("mydate" , s.toString());     }            @OnItemClick(R.id.list)     void onItemClick(int position) {         Toast.makeText(this, position + "", Toast.LENGTH_SHORT).show();     }   }
  | 
 
版权声明:遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文地址:https://blog.csdn.net/qq_38261174/article/details/79821093