User interface and Summary of activities:
1 User interface:
~android:id= "" is specifically used to locate the index of the specified interface if you want to invoke the control in a later program, be sure to define this property
~ How the control is referenced: XML in @id/** code in r.id.**
<textview
Android:layout_width= "Wrap_content"
abdroid:layout_height= "Wrap_content"
Android:text= ".."
/>
<edittext
android:layout_height= "Wrap_content"
Android:layout_width= "Wrap_content"
Android:inputtype= "The place can decide which content data type to enter"/>
<button
Android:id= "@+id/**"
android:layout_height= "Wrap_content"
Android:layout_width= "Wrap_content"
android:text= "button"
Android:onclick (How can I set the click button in XML?) )/>
The Select control can call IsChecked () to verify which button is selected
<checkbox
android:layout_height= "Wrap_content"
Android:lalout_width= "Wrap_content"
android:checked= "True/false"/>
Used to create a collection with a selection function
<radiogroup
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:orientation= "Horizontal" >
<radiobutton
android:text= "-"
android:layout_height= "Wrap_content"
Android:layout_width= "Wrap_content"/>
<radiobutton
android:text= "+"
android:layout_height= "Wrap_content"
Android:layout_width= "Wrap_content"/>
</RadioGroup>
Menu use: Create a menu lalout file definition <item android:id= "@+id/item1"
android:icon= "@drawable/rightarrow"
android:title= "Item1"/>
<item .....
/>
public boolean Oncreateoptionsmenu (Menu menu) {
Menuinflater Inflater=getmenuinflater ();
return Super.oncreateoptionmenu (menu);
}
Response Menu Events
public boolean onoptionitemselected (MenuItem item) {
Swith (Item.getitemid ()) {
Case R.ID.ITEM1:
..
Break
Case R.ID.ITEM2:
..
break;}
return super.onoptionitemselected (item);}
2 Activities:
~ Three ways to start a campaign: Declare the first activity to enter in the manifest file
Use the Contentwrapper object's startacticity () to start the activity
Using Startactivityforresults
~<action android:name= "Android.intent.action.MAIN"/>//indicates that the activity is a program entry point
<category android:name= "Android.intent.category.LAUNCHER"/>//display the program icon in the installation list
~setcontentview (int)
Finfviewbyid (r.****)
Setonclicklistener (New Onclicklistener () {
@Override
public void OnClick (View V) {}
});
~ Activity management is the use of stack management
The ~android system does not proactively remove any activity that has been used unless it is not enough memory to turn it off by priority
~ Create Event handling method has two Android:onclick and use anonymous inner class **.setonclicklistener (new Onclicklistener () {public void OnClick (View void) {}});
~ Long press event handling. Setonlongclicklistener (new Onclicklistener () {piblic void Onlongclick () {}});
~toast.maketext (This, "", Toast.length_short). Show (); pop up a temporary text event
~ Use Intent to initiate activity step: 1 Create an Activity click button to trigger the second activity 2 define a second activity and a separate layout 3 the name of the action and category and the secondary activity of the primary activity registered in manifest
~ Transfer data between activities: Send:
Intent intent=new Intent (this,activity.class);
Bundle Bundle=new Bundle ();
Bundle.putstring ("Key value", A.gettext (). toString);
Intent.putextra (bundle); Attach the bundle to the next
Startacticity (Intent);
Receive: Bundle bundle=this.getintent (). Getextras ();
if (bundle!=null) {C=integer.pareint (bundle.getstring ("Key value")}
~ Launch the built-in application
Intent intent=new Intent (Intent. Action_view,uri.parse ("http://www.google.com.hk")); startacticity (intent);
Android (Eclipse) interface controls and activity summary (ii)