In my last example we have discussed about the text view. Now we are moving towards the button control.
Now add button control to the android activity.
Figure 1
Now move to its xml coding
Figure 2
Here you can change the text of the button and id of the button. Which you can also change by double clicking on button.
Let’s I have set the button id b1 and button text click me.
Now I want to add button even onclick. So I have created a function in java file which is related to this activity and bind this function with button onclick event.
public void btn_click(View v)
{
}
Figure 3
Now change the text of textview on button click
public void btn_click(View v)
{
TextView t1=(TextView)findViewById(R.id.txt_data);
t1.setText("button has been clicked");
}
Now execute the code
Figure 4
Figure 5
For any query you can send mail at info@techaltum.com