Android Button control binding Click Event
Package com. android. test;
Import android. app. Activity;
Import android. OS. Bundle;
Import android. view. View;
Import android. widget. Button;
Import android. widget. TextView;
Import android. widget. Toast;
Public class ButtonDemo extends Activity {
Private TextView textview1;
Private Button button1;
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
// Locate the TextView and Button controls defined in main. xml by ID
Textview1 = (TextView) findViewById (R. id. textview1 );
Button1 = (Button) findViewById (R. id. button1 );
// Add Event Response
Button1.setOnClickListener (new View. OnClickListener (){
Public void onClick (View v)
{
// Toast prompt control
Toast. makeText (ButtonDemo. this,
"The text in TextView has changed. Have you noticed it? ",
Toast. LENGTH_LONG). show ();
// Change the TextView text
Textview1.setText ("welcome to the 400 phone reception center, our URL is: http://www.my400800.cn! ");
}
});
}
}
Author: "I love technology"