Import Android. App. activity;
Import Android. OS. Bundle;
Import Android. widget. Button;
Import Android. content. dialoginterface;
Import Android. content. dialoginterface. onclicklistener;
Import Android. content. intent;
Import Android. View. view;
Public class activity_01activity extends activity {
/** Called when the activity is first created .*/
Private button mybutton = NULL;
@ Override
Public void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
Setcontentview (R. layout. Main );
Mybutton = (button) findviewbyid (R. Id. mybutton );
Mybutton. settext ("second activity ");
Mybutton. setonclicklistener (New mybuttonlistener ());
}
/*
Class mybuttonlistener implements onclicklistener {
@ Override
Public void onclick (dialoginterface dialog, int which) {// when you move the cursor over mybuttonlistener, a prompt is displayed. Click Add. This is the default function.
// Todo auto-generated method stub
Intent intent = new intent ();
Intent. setclass (activity_01activity.this, otheractivity. Class );
Activity_01activity.this.startactivity (intent );
}
}
*/
Class mybuttonlistener implements Android. View. View. onclicklistener {
@ Override
Public void onclick (view v ){
// Todo auto-generated method stub
Intent intent = new intent ();
Intent. setclass (activity_01activity.this, otheractivity. Class );
Activity_01activity.this.startactivity (intent );
}
}
}
/***/The comment Part replaces the following class mybuttonlistener implements Android. View. View. onclicklistener,
The following error occurs: mybutton. setonclicklistener (New mybuttonlistener ());
In the sentence, setonclicklistener is displayed in the red line. When you move the cursor over it, the following message is displayed:
The method setonclicklistener (view. onclicklistener) in the type view is not applicable for the arguments (activity_01activity.mybuttonlistener)
If it is written above, comment out the error description and run it without errors.
PS is just getting started. If someone else doesn't see the answer they want, just give it a try. Haha