I just learned about Android and saw that the events in the book have always been fixed. I am not quite clear about this in Java. What kind of Anonymous class should I think, the event can be specified at runtime for flexibility.
So I searched from the Internet (my foundation is poor, there is no way ).
Lab successfulCode:
Package Android. zziss. Hello;
Import Android. App. activity;
Import Android. OS. Bundle;
Import Android. View. view;
Import Android. widget. Button;
Import Android. widget. Toast;
public class helloactivity extends activity {
/** called when the activity is first created. */
private button m_button;
private btnlistener Lis;
@ override
Public void oncreate (bundle savedinstancestate) {
super. oncreate (savedinstancestate);
setcontentview (R. layout. main);
m_button = (button) This. findviewbyid (R. id. btn1);
Lis = new btnlistener ();
m_button.setonclicklistener (LIS);
}< br>
}
Class btnlistener implements view. onclicklistener
{
Public void onclick (view v ){
// Todo auto-generated method stub
Button BTN = (button) V;
BTN. settext ("AAAAA ");
}
}
It's easy, but I didn't know it at the time. It seems that the basics are not good. I still have to learn the basics.
For the first Android project, record it