android studio button click event code example
Example 1: button listener android
public class MyActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.my_layout_id);
final Button button = (Button) findViewById(R.id.my_cool_button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
}
}
Example 2: onclicklistener in android studio
Name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this,FileName.class));
}
});
Example 3: android onlcik java
Button button = (Button) findViewById(R.id.button_send);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
Example 4: onclick listener android
Button myButton;
awesomeButton = new Button(this);
awesomeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this,NewActivity.class));
});
}
Example 5: onclick method android
public void clickFunction (View view){}