Method 1:
Method 2:
https://stackoverflow.com/questions/10231309/android-button-onclick
https://stackoverflow.com/questions/29603834/butterknife-onclick-is-not-working
public void onClick(View v) {
Intent i = new Intent(currentActivity.this, SecondActivity.class);
startActivty(i);
}
Method 2:
Button button = (Button) findViewById(R.id.mybutton);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(this, "Button Clicked", Toast.LENGTH_LONG).show();
}
});
Method 3:@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
}
@OnClick(R.id.button)
void submitButton(View view) {
Toast.makeText(this, "Click", Toast.LENGTH_SHORT).show();
}
@Override
protected void onDestroy() {
// defined in 'top level' of activity, not nested within another block
// code here is executed when the user quits the activity.
super.onDestroy();
mSearchedLocationReference.removeEventListener(mSearchedLocationReferenceListener);
}
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'https://stackoverflow.com/questions/10231309/android-button-onclick
https://stackoverflow.com/questions/29603834/butterknife-onclick-is-not-working
Comments
Post a Comment