تشترك الأمثلة الواردة في هذه المقالة في جميع رموز Java لتنفيذ تسجيل بسيط وتحديد المدينة التي تقع عليها للرجوع إليها. المحتوى المحدد كما يلي
1.Activity_main.xml
<؟ Android: layout_height = "fill_parent"> <textview android: layout_width = "wall_content" Android: layout_height = "wall_content" Android: text = "username:" /> <edittext android: id = "@id /user" Android: minwidth = Android: layout_height = "wall_content" /> <linearlayout android: gravity = "center_vertical" android: layout_width = "match_parent" android: layout_height = "wall_content"> <textview android: layout_width = "wall_content <RadiOgroup Android: id = "@id/sex" Android: extream = "horizontal" Android: layout_width = "wall_content" android: layout_height = "wall_content"> <radiObutton android: id = "@id/radio0" leghout_width = "wrap_content" Android: checked = "true" Android: text = "male"/> <radiobutton android: id = "@id/radio1" Android: layout_width = "wall_content" android: layout_height = "wrap_content" android: "woman"/> </radioGroup> </linearlayout> Android: layout_width = "wall_content" Android: layout_height = "wall_content"> <textView android: id = "@+id/textView1" Android: text = "الرجاء تحديد مدينتك: Android: oundries = "@array/ctype" Android: layout_height = "wall_content" Android: layout_width = "wall_content" Android: id = "@id/spinner1"/> </linearlayout> <textview Android: layout_width = "wrap_content" android: "layout_height" Android: text = "password:"/> <edittext android: id = "@+id/pwd" Android: minwidth = "200px" Android: inputType = "TextPassword" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"/> Android: layout_height = "wall_content" android: text = "تأكيد كلمة المرور:" /> <edittext android: id = "@id /repwd" android: minwidth = "200px" android: inputType = "textPassword" Android: id = "@+id/textView3" Android: layout_width = "wall_content" Android: layout_height = "wrap_content" android: text = "ed mail: Android: layout_height = "wall_content" /> <button android: id = "@+id /president
2.register.xml
<؟ Android: layout_height = "wrap_content" Android: padding = "10px" Android: text = "username:" /> <textView android: id = "@+id /sex" Android: layout_width = "rab_content" Android: layout_height = "wrap_content" android: " Android: id = "@+id/city" Android: layout_width = "wall_content" Android: layout_height = "wall_content" Android: padding = "10px" Android: text = "city: Android: padding = "10px" Android: text = "password:" /> <textView android: id = "@id /email الخطوة "Android: layout_width =" wall_content "Android: layout_height =" wall_content " /> </linearlayout>
3. MainActivity.Java
حزمة com.example.ejcker_llin.myapplication ؛ استيراد Android.App.activity ؛ استيراد Android.content.intent ؛ استيراد Android.Support.v7.app.appCompativitive ؛ استيراد Android.os.bundle ؛ import android.view ؛ import Android.widget.adapterview ؛ import Android.widget.button ؛ import. Android.widget.radiogroup ؛ استيراد Android.widget.spinner ؛ استيراد Android.widget.toast ؛ يمتد النشاط الرئيسي للطبقة العامة النشاط {إرسال زر خاص ؛ سلسلة خاصة sex1 ؛ سيتي سلسلة خاصة ؛ رمز int النهائي = 0x717 ؛ Override محمية void onCreate (backdle SaveInstancestate) {super.oncreate (SaveInstancestate) ؛ setContentView (r.layout.activity_main) ؛ إرسال = (زر) FindViewById (r.id.submit) ؛ submit.setOnClickListener (new view.onclickListener () {Override public void onClick (view v) {string user = ((edittext) findViewById (r.id.user)). getText (). repwd = (edittext) findViewByid (r.id.repwd). getText () i = 0 ؛ i <extchildcount () ؛ i ++) {radiobutton r = (radiobutton) AdapterView.OnitemSelectedListener () {Override public void onItemSelected (AdapterView <؟> view ، عرض int ، معرف طويل) {city = parent.getItemAtposition (position) .toString () ؛ إذا (! "". يساوي (المستخدم) &&! "". يساوي (pwd) &&! ". "، toast.length_long) .show () ؛ ((edittext) findViewById (r.id.pwd)). intent (Bundled. intent.putextras (حزمة) ؛ 4. registeracivity.java
حزمة com.example.ejcker_llin.myapplication ؛ استيراد Android.App.activity ؛ استيراد Android.content.intent ؛ استيراد Android.Os.Bundle ؛ Import Android.view.view ؛ استيراد Android.widget.button ؛ استيراد Android.widget.textView ؛ /*** تم إنشاؤه بواسطة JCker_llin في 2016/4/5. */regivity الفئة العامة يمتد النشاط {override void onCreate (bundle saveInstancestate) {super.oncreate (saveInstancestate) ؛ setContentView (R.Layout.register) ؛ نية النية النهائية = getIntent () ؛ حزمة bundle = intent.getExtras () ؛ TextView user = (TextView) findViewById (r.id.user) ؛ user.settext ("username:"+bundle.getString ("user")) ؛ TextView Sex = (TextView) FindViewById (R.ID.Sex) ؛ sex.settext ("الجنس:"+bundle.getString ("sex")) ؛ TextView City = (TextView) FindViewById (R.Id.City) ؛ City.Settext ("City:"+Bundle.getString ("City")) ؛ TextView pwd = (textView) findViewById (r.id.pwd) ؛ pwd.settext ("كلمة المرور:"+bundle.getString ("pwd")) ؛ TextView email = (textView) findViewById (r.id.email) ؛ البريد الإلكتروني. زر زر = (زر) findViewById (r.id.back) ؛ button.setonClickListener (new view.onclickListener () {Override public void onClick (view v) {setResult (0x717 ، intent) ؛ finish () ؛}}) ؛ }}5.
6.
7. صفائف. xml
<؟ <Item> xi'an </item> <item> آخر </item> </string-array> </srossial>
ما سبق هو كل شيء عن هذا المقال ، آمل أن يكون مفيدًا لتعلم الجميع.