この記事の例は、Javaのすべてのコードを共有して、簡単な登録を実装し、参照用に配置されている都市を選択します。特定のコンテンツは次のとおりです
1.Activity_main.xml
<?xml version = "1.0" encoding = "utf-8"?> <linearlayout xmlns:android = "http://schemas.android.com/apk/res/android" xmlns:ツール= "http://schemas.android.com Android:layout_width = "fill_parent" android:layout_height = "fill_parent"> <textView android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "" username: /> <editt android = "@ad" Android:minwidth = "200px" android:layout_width = "wrap_content" android:layout_height = "wrap_content" /> <linearlayout android: "center_vertical" android:layout_width = "match_perted" layout_height "> <height Android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "gender:" /> <radiogroup android: "@+id /sex" android:orientation = "horizontal" android:layout_width = "wrap_content" "lap_content" android:layout_height = "wrap_content"> <radiobutton android:id = "@+id/radio0" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:checked = "android:" Male "/>" odadiovidton " android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "woman"/> </radiogroup> </rilearlayout android:orientation = "vertical" android:layout_width = "wrap_content" "" lap_content "" Android:layout_height = "wrap_content"> <textView android:id = "@+id/textview1" android:text = "" android:layout_height = "wrap_content" android:layout_width = "wrap_content"/> <spinner androident " android:layout_height = "wrap_content" android:layout_width = "wrap_content" android: "@+id/spinner1"/> </linearlayout> <textview android:layout_width = "wrap_content" android: "wrap_content" <edittext android:id = "@+id /pwd" android:minwidth = "200px" android:inputtype = "textpassword" android:layout_width = "wrap_content" android:layout_height = "wrap_content" /> <textview android: "width =" " Android:layout_height = "wrap_content" android:text = "prassid:" /> <editext android: "@+id /repwd" android = "200px" android:inputtype = "textpassword" android:layout_width = "lap_content" android " /> <textView android:id = "@+id /textView3" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "e-mailアドレス:" /> <edittextext android:id = "@+id /id /id" android:minwidth = "400px" " Android:layout_width = "wrap_content" android:layout_height = "wrap_content" /> <button android:id = "@+id /submit" android_width = "wrap_content" android:layout_height = "wrap_content" android: "
2.Register.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 Android:layout_height = "wrap_content" android:padding = "10px" android:text = "username:" /> <textview android: "@+id /sex" android:layout_width = "wrap_content" android:layout_height = "lap_content =" android Android:text = "gender:" /> <textview android:android: "@+id /city" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:padding = "10px" android:text = "" /> <textview android: "@pd" Android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:padding = "10px" android:text = "password:" /> <textview android:id = "@+id /eclais" android: "padding =" "android:layout_widtent" android:layout_height = "wrap_content" android:text = "e-mail:" /> <button android: "@+id /back" android: "back back to begute step" androeout_width = "wrap_content" android:layout_heigh
3。MainActivity.java
パッケージcom.example.ejcker_llin.myapplication; import android.app.Activity;import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.AdapterView;import android.widget.Button;import android.widget.EditText;import android.widget.radiobutton; Import android.widget.radiogroup; Import android.widget.spinner; Import android.widget.toast;パブリッククラスのMainActivityはアクティビティを拡張します{プライベートボタン送信;プライベートストリングsex1;プライベートストリングシティ; final int code = 0x717; @Override Protected void oncreate(bundle savedinstancestate){super.oncreate(savedinstancestate); setContentView(r.layout.activity_main); submit =(button)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)) i = 0; sex.getChildCount(); i ++){radiobutton) adapterView.OnitemSelectedListener(){@Override public void onitemselected(adapterview <? if(! ""。equals(user)&&! ""。equals(pwd)&& "、toast.length_long).show();((edittext)findViewByid(r.id.pwd))。 Intent(This Registeracivity.class); intent.putextras(intent); 4。RegisterAcivity.java
パッケージcom.example.ejcker_llin.myapplication; Android.app.Activityをインポート; Import android.content.intent; Import android.os.bundle; import android.view.view; Import android.widget.button; Import android.widget.textview; /*** 2016/4/5にjcker_llinによって作成されました。 */public class RegisterAcivityはアクティビティを拡張します{@Override Protected void oncreate(bundle savedinstancestate){super.oncreate(savedinstancestate); setContentView(r.layout.register);最終的な意図= getIntent(); bundle 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( "gender:"+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( "password:"+bundle.getString( "pwd")); textView email =(textView)findViewById(r.id.email); email.settext( "電子メール:"+bundle.getString( "email"));ボタンボタン=(ボタン)findViewByID(R.ID.BACK); button.setOnclickListener(new View.onclickListener(){@Override public void onclick(View v){setResult(0x717、Intent); finish();}}); }}5。
6。
7。ARRAYS.XML
<?xml version = "1.0" encoding = "utf-8"?> <resource> <string-array name = "ctype"> <item> beijing </item> <item> itemai </item> <item> <item> xi'an </item> <item>その他</item> </string-array> </resources>
上記はこの記事に関するものです。すべての人の学習に役立つことを願っています。