Reputation: 698
I write the following code in MainActivity.java.This code is about on the click of the button. Suppose There is a default text "dhaval" But when I click on the button 'WELCOME' the text shoud be changed like "Hi!This is Dhaval's First App".So I write the onClick of the button the function public void Showmsg()
In this I can't understand why we pass 'View object' as a parameter?
Following code I written:
public void Showmsg(View v)
{
TextView tv =(TextView) findViewById(R.id.textView1);
tv.setText("Hi!This is Dhaval's First App");
}
Upvotes: 0
Views: 71
Reputation: 83527
Every onClick
method must have a View
parameter. This is a reference to the view which was clicked.
Upvotes: 1