I injected views perfectly using butterknife library. But when I try to implement listeners, for example onclick
I'm not able to implement them. Following java code will help you to understand my problem.
Java code:
public class LoginActivity extends ActionBarActivity{
@InjectView(R.id.toolbar) Toolbar toolbar;
@InjectView(R.id.btn_login) Button login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
ButterKnife.inject(this);
initialize();
//initListeners();
@OnClick(R.id.btn_login)
public void submit(View view) {
// TODO submit data to server...
}
}
/*private void initListeners() {
@OnClick(R.id.btn_login)
public void login(){
}
}*/
private void initialize() {
setSupportActionBar(toolbar);
getSupportActionBar().setIcon(R.drawable.toolbar_icon);
getSupportActionBar().setTitle(null);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
}
Tell me why it is happening. Anything wrong in code? I've already configured the IDE which is compatible with ButterKnife by using following URL.
https://mcmap.net/q/536694/-onclick-is-not-working-in-implementation-of-butterknife-library
Please give me any suggestions regarding this issue. Thanks in Advance..