TextView, EditText, password EditText, RadioButton, Button, Spinner, CheckBox, ToggleButton
1. Engineering Catalogue
2, Test_changyongzujian.java
Package Com.example.test_changyongzujian;import Android.os.bundle;import Android.app.activity;import Android.content.intent;import Android.view.menu;import Android.view.view;import Android.view.View.OnClickListener ; Import Android.widget.arrayadapter;import Android.widget.button;import Android.widget.checkbox;import Android.widget.edittext;import Android.widget.radiobutton;import Android.widget.spinner;import Android.widget.togglebutton;public class Test_changyongzujian_activity extends Activity {private Button CancelButton, Registerbutton;private EditText usernameedit, passwordedit;private RadioButton Maleradio, femaleradio;private ToggleButton marrigetoggle;private CheckBox Readingcheck, swimmingcheck;private Spinner positionspinner;@ overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.test_changyongzujian) Usernameedit = (EditText) Findviewbyid (r.id.username);p Asswordedit = (EditText) Findviewbyid (R.id.password); MaleraDio = (RadioButton) Findviewbyid (r.id.male); Femaleradio = (RadioButton) Findviewbyid (r.id.female); marrigetoggle = ( ToggleButton) Findviewbyid (r.id.marriged) Readingcheck = (CheckBox) Findviewbyid (r.id.reading); Swimmingcheck = ( CheckBox) Findviewbyid (r.id.swimming);//Spinnerpositionspinner = (Spinner) Findviewbyid (r.id.position); string[] str = {"CEO", "CFO", "PM"}; Arrayadapter AA = new Arrayadapter (this,android. R.layout.simple_spinner_item, str);p ositionspinner.setadapter (AA);//Buttoncancelbutton = (Button) Findviewbyid ( R.id.cancel) Registerbutton = (Button) Findviewbyid (r.id.register); Registerbutton.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubbundle B = new Bundle (); B.pu Tstring ("username", "User name:" + Usernameedit.gettext (). toString ()); B.putstring ("Password", "User password:" + Passwordedit.gettext (). toString ()), if (maleradio.ischecked ()) b.putstring ("Gender", "Gender: Male"), else if ( Femaleradio.ischecked ()) b.putstring ("Gender", "Gender: female "); String temp = "hobby:"; if (readingcheck.ischecked ()) {temp + = "read";} else if (swimmingcheck.ischecked ()) {temp + = "swim";} B.putstring ("hobby", temp), if (marrigetoggle.ischecked ()) b.putstring ("Marrige", "Married No: Married"); Elseb.putstring ("Marrige "," No Marriage: Unmarried "); B.putstring (" Position ", Positionspinner.getselecteditem (). toString ()); Intent Intent = new Intent (test_ Changyongzujian_activity.this,result.class); Intent.putextra ("Data", b); startactivity (intent);}}); @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action bar if it is PR Esent.getmenuinflater (). Inflate (R.menu.test_changyongzujian_, menu); return true;}}
3, Result.java
Package Com.example.test_changyongzujian;import Java.util.arraylist;import Java.util.list;import Android.app.activity;import Android.content.intent;import Android.os.bundle;import Android.widget.ArrayAdapter; Import Android.widget.listview;public class Result extends Activity {private ListView listview; @Overrideprotected void OnCreate (Bundle savedinstancestate) {//TODO auto-generated method Stubsuper.oncreate (savedinstancestate); Setcontentview (r.layout.result); listview = (ListView) Findviewbyid (R.ID.LISTVIEW01);//Gets the value passed over the last page intent intent = This.getintent (); Bundle B = Intent.getbundleextra ("Data"); List List = new ArrayList (), List.add (b.getstring ("username")), List.add (b.getstring ("password")), List.add ( B.getstring ("Gender")), List.add (b.getstring ("hobby")), List.add (b.getstring ("Marrige")), List.add (B.getstring (" Position "));//ListView Settings Adapter Arrayadapter adapter = new Arrayadapter (this,android. r.layout.simple_list_item_checked, list); Listview.setadapter (adapter);}}
4, Test_changyongzujian.xml
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "Match_parent" android:layout_height= "match_parent" android:orientation= "vertical" > <tablelayout android:id= "@+id/tab leLayout01 "android:layout_width=" wrap_content "android:layout_height=" wrap_content "> <tablero W android:id= "@+id/tablerow01" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" > <textview android:id= "@+id/textview01" Android:layout_widt H= "Wrap_content" android:layout_height= "wrap_content" android:text= "User name"/> & Lt EditText android:id= "@+id/username" android:layout_width= "Wrap_content" Andro id:layout_height= "wrap_content" android:text= "/> </TableRow> <tablerow Android:id= "@+id/tableRow02 "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "> < TextView android:id= "@+id/textview02" android:layout_width= "Wrap_content" and roid:layout_height= "wrap_content" android:text= "User password"/> <edittext android: Id= "@+id/password" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:password= "true" android:text= ""/> </TableRow> <tablerow Android:id= "@+id/tablerow03" android:layout_width= "wrap_content" android:layout_height= "WR Ap_content "> <textview android:id=" @+id/textview03 "android:layout_width=" Wrap_content "android:layout_height=" wrap_content "android:text=" gender "/> <ra DiogroupAndroid:id= "@+id/gender_g" android:layout_width= "wrap_content" android:layout_height= "Wrap_c Ontent "> <radiobutton android:id=" @+id/male "Android:layout_wi Dth= "Wrap_content" android:layout_height= "wrap_content" android:text= "male"/> <radiobutton android:id= "@+id/female" android:layout_width= "Wrap_conten T "android:layout_height=" wrap_content "android:text=" female "/> </radio group> </TableRow> <tablerow android:id= "@+id/tablerow04" Android:layout_w Idth= "Wrap_content" android:layout_height= "wrap_content" > <textview android:id = "@+id/textview04" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:text= "Marriage No"/> <togglebutton android:id= "@+id/marriged" android:layout_width= " Wrap_content "android:layout_height=" wrap_content "android:text=" @+id/togglebutton01 "/> </TableRow> <tablerow android:id= "@+id/tablerow05" android:layout_width= "wrap _content "android:layout_height=" wrap_content "> <textview android:id=" @+id/hob By "android:layout_width=" Wrap_content "android:layout_height=" Wrap_content " android:text= "Hobby"/> <checkbox android:id= "@+id/reading" Android:layout_wid Th= "Wrap_content" android:layout_height= "wrap_content" android:text= "read"/> &l T CheckBox android:id= "@+id/swimming" android:layout_width= "Wrap_content" Andro id:layout_height= "Wrap_content "android:text=" swimming "/> </TableRow> <tablerow android:id=" @+id/ TableRow06 "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "> <textview android:id= "@+id/textview05" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "title"/> <spinner Androi D:id= "@+id/position" android:layout_width= "wrap_content" android:layout_height= "wrap_content "/> </TableRow> <tablerow android:id=" @+id/tablerow07 "Android:layout_wid Th= "Wrap_content" android:layout_height= "wrap_content" > <button android:id= "@+ Id/cancel "android:layout_width=" wrap_content "android:layout_height=" Wrap_content " Android:text= "Cancel" /> <button android:id= "@+id/register" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "register"/> </TableRow> < ;/tablelayout></linearlayout>
5, Result.xml
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:layout_width=" match_parent " android:layout_height=" match_parent " android:o rientation= "vertical" > <listview android:id= "@+id/listview01" android:layout_width= "Wrap_ Content " android:layout_height=" wrap_content "> </ListView></LinearLayout>
6, Androidmenifest.xml
Need to add Result.java activity
7. Results show
Android application Development detailed (eight)-------------common components