Android (Eclipse) interface controls and activity summary (ii)

Source: Internet
Author: User

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**
Android:layout_width= "Wrap_content"
abdroid:layout_height= "Wrap_content"
Android:text= ".."
android:layout_height= "Wrap_content"
Android:layout_width= "Wrap_content"
Android:inputtype= "The place can decide which content data type to enter"/>
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
android:layout_height= "Wrap_content"
Android:lalout_width= "Wrap_content"
android:checked= "True/false"/>
Used to create a collection with a selection function
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:orientation= "Horizontal" >

android:text= "-"
android:layout_height= "Wrap_content"
Android:layout_width= "Wrap_content"/>
android:text= "+"
android:layout_height= "Wrap_content"
Android:layout_width= "Wrap_content"/>
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:
Case R.ID.ITEM2:
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 () {
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 ("")); startacticity (intent);

Android (Eclipse) interface controls and activity summary (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.