Button(this) android code example
Example 1: android studio button usage
//this for xml file
//this for java file
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//do something
}
});
}
Example 2: button android stdui
Button b = findById();