Android Buffet Control Annotated IOC
- Android Buffet Control Annotated IOC
- Supported events
- Use steps
Supported Events:
- OnCheckedChanged ()
- OnClick ()
- Oneditoraction ()
- Onfocuschange ()
- Onitemclick ()
- Onitemlongclick ()
- Onitemselected ()
- Onlongclick ()
- Onpagechange ()
- OnTextChanged ()
- OnTouch ()
Use steps
- First add in the
build.gradle
compile ‘com.jakewharton:butterknife:7.0.1‘
- It is then called in the oncreate of the activity
ButterKnife.bind(this);
- You can then use annotations to bind controls or click events.
public class MainActivity extends AppCompatActivity {
@Bind(R.id.tv_test1) TextView tvT1;
@Bind(R.id.tv_test2) TextView tvT2;
@Bind(R.id.tv_test3) TextView tvT3;
@Bind(R.id.tv_test4) TextView tvT4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
tvT1.setText("text");
}
@OnClick({R.id.tv_test1,R.id.tv_test2})
void test1Clicked(View v){
Toast.makeText(this,v.getId()+"",Toast.LENGTH_SHORT).show();
}
}
Android Buffet Control Annotated IOC