Formally began to learn Android, no reading and video, so there is no systematic study, just see which knowledge points to learn, today learning interface between the jump, as well as the value, the main point of knowledge is intent,
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
LinearLayout view = new LinearLayout (Getapplicationcontext ());
Setcontentview (view);
Settitle ("This is an activity");
Button button = New button (Getapplicationcontext ());
Button.settext ("Click I jump to the next screen");
View.addview (button);
Button.setonclicklistener (New Onclicklistener () {
@Override
public void OnClick (View arg0) {
Intent Intent = new Intent ();
Intent.setclass (Getapplicationcontext (), activitytest1.class);
Intent.putextra ("Key", "11");
Startactivityforresult (Intent, 1);
}
});
}
SetClass indicates which page to jump to, PutExtra represents the value to be passed to the next interface, similar to the Key,value method.
StartActivity () just jump to the target page, if you want to jump back to the current page, you must use the startactivity () again;
This task can be done one time, when the program executes to this code, if from T1activity jump to the next text2activity, and when the text2activity call the Finish () method, the program will automatically jump back t1activity , and call the Onactivityresult () method in the previous t1activity.
@Override
protected void Onactivityresult (int requestcode, int resultcode, Intent data) {
Super.onactivityresult (Requestcode, ResultCode, data);
System.out.println (requestcode+ ":::: Requestcode");
System.out.println (resultcode+ ":::: ResultCode");
if (Requestcode = = ResultCode) {
Bundle bundle = Data.getextras ();
String param = bundle.getstring ("active1");
Settitle (param);
}
}
An additional interface
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (r.layout.second_activity);
LinearLayout view = new LinearLayout (Getapplicationcontext ());
Setcontentview (view);
Bundle bundle = Getintent (). Getextras ();
if (bundle! = null) {
Settitle ("Main Interface" +bundle.getstring ("key"));
}
Button button = New button (Getapplicationcontext ());
Button.settext ("Click I jump to the previous screen");
View.addview (button);
Button.setonclicklistener (New Onclicklistener () {
@Override
public void OnClick (View arg0) {
Bundle bundle = new bundle ();
Bundle.putstring ("active1", "This is the data transmitted by the Activity1");
Intent Intent = new Intent ();
Intent.putextras (bundle);
Setresult (1,intent);
Finish ();
}
});
}
Android Learning Path--------Intent