February 15 learning log

Today focuses on the development of family books and notes Andrews Studio learning.

 

Study notes:

1.
Page Jump Use Intent

Intent to assist with communication between the various components of Android.

2.
Add Data: Intent.putExtra (key, value);
Get Data: Intent.getTypeExtra (key);
custom java classes.

3.

1) New Page:
New page in MainActivity a FristActivity.java, inherited from AppCompatActivity (Enter)
to create a new protected void onCreate () in FristActivity.java in;
write setContentView (R.layout.activity_frist) in the function; // call activity_frist.xml


protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_frist);
}

 

2) old page call:

New method: initUI (); // initialize
the new method in the new listener: findViewById (R.id.btn1) .setOnClickListener (this ); // Create a listener for btn1
in: onClick (View v) method:

{
// jump codes
the Intent the Intent Intent new new = ();
intent.setClass (getApplicationContext (), FristActivity.class); // Do not forget to jump back page .class
startActivity (Intent);

}


3) Finally, a new statement in the AnriondmanActivity.xml <activity />

Guess you like

Origin www.cnblogs.com/sicilya/p/12315349.html