0
Explain this code
Button b = (Button)findViewById(R.id.button1); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(),"Nitya is a good girl",Toast.LENGTH_LONG).show(); } });
1 Answer
0
Button b = (Button)findViewById(R.id.button1); //Create a reference to button1 called b
b.setOnClickListener(new View.OnClickListener() { //add event listener to b
@Override //override the onClick method
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"Nitya is a good girl",Toast.LENGTH_LONG).show(); //show a toast message in the application context during long (3 seconds if i well remember)
}
});