Collection of Android development tips

  • 2020-12-16 06:06:35
  • OfStack

1. For too many controls, the function is similar, the number is too much, can use include method. In the implementation application, you can place controls into the List collection.


private void initView() {
// TODO Auto-generated method stub
pwd1 = (EditText) findViewById(R.id.pwd_et_6_1);
pwd2 = (EditText) findViewById(R.id.pwd_et_6_2);
pwd3 = (EditText) findViewById(R.id.pwd_et_6_3);
pwd4 = (EditText) findViewById(R.id.pwd_et_6_4);
pwd5 = (EditText) findViewById(R.id.pwd_et_6_5);
pwd6 = (EditText) findViewById(R.id.pwd_et_6_6);
list.add(pwd1);
list.add(pwd2);
list.add(pwd3);
list.add(pwd4);
list.add(pwd5);
list.add(pwd6);
for (int i = 0; i < list.size(); i++) {
list.get(i).addTextChangedListener(watcher);
list.get(i).setOnKeyListener(delete);
}
} 

The above content is relatively short, a brief introduction to Android development tips collection related knowledge, I hope you enjoy.


Related articles: