<?xml version="1.0"encoding="Utf-8"? ><linearlayout xmlns:android="http://schemas.android.com/apk/res/android"Xmlns:tools="Http://schemas.android.com/tools"Android:id="@+id/activity_main"Android:layout_width="match_parent"Android:layout_height="match_parent"Android:paddingbottom="@dimen/activity_vertical_margin"Android:paddingleft="@dimen/activity_horizontal_margin"Android:paddingright="@dimen/activity_horizontal_margin"Android:paddingtop="@dimen/activity_vertical_margin"Tools:context="com.example.administrator.married.MainActivity"android:orientation="Vertical"Android:weightsum="1"> <TextView Android:text="Gender:"Android:layout_width="wrap_content"Android:layout_height="wrap_content"android:textsize="40DP"Android:textcolor="@android: Color/black"Android:id="@+id/sex"/> <EditText android:layout_width="match_parent"Android:layout_height="wrap_content"Android:inputtype="Textpersonname"Android:ems="Ten"Android:id="@+id/edtsex"Android:hint="(input gender)"Android:singleline="false"/> <TextView Android:text="Age:"Android:layout_width="wrap_content"Android:layout_height="wrap_content"android:textsize="40DP"Android:textcolor="@android: Color/black"Android:id="@+id/age"/> <EditText android:layout_width="match_parent"Android:layout_height="wrap_content"Android:inputtype="Textpersonname"Android:ems="Ten"Android:id="@+id/edtage"Android:hint="(input age)"/> <Button Android:text="Determine"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:id="@+id/btnok"android:layout_gravity="Center_horizontal"android:textsize="40DP"android:elevation="24DP"/> <TextView Android:text="@string/result"Android:layout_width="wrap_content"Android:layout_height="wrap_content"android:textsize="40DP"Android:textcolor="@android: Color/black"
Packagecom.example.administrator.married;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.widget.EditText;Importandroid.widget.*; Public classMainactivityextendsappcompatactivity {EditText medtsex,medtage; TextView mtxtr; Button Mbtnok; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); Medtsex=(EditText) Findviewbyid (r.id.edtsex); Medtage=(EditText) Findviewbyid (r.id.edtage); MTXTR=(TextView) Findviewbyid (R.ID.TXTR); Mbtnok=(Button) Findviewbyid (R.id.btnok); Mbtnok.setonclicklistener (Btnokonclick); } PrivateView.onclicklistener Btnokonclick =NewView.onclicklistener () { Public voidOnClick (View v) {String strsex=Medtsex.gettext (). toString (); intIage=Integer.parseint (Medtage.gettext (). toString ()); String Strsug=getString (R.string.result); if(Strsex.equals ("Male")){ if(iage<28) {Strsug+ = "Chico tell you: Not urgent"; } Else if(iage>33) {Strsug+ = "Chico tell you: Get married soon!"; } Else{Strsug+ = "Chico tell you: Start looking for the object!"; } } Else{ if(iage<25) {Strsug+ = "Chico tell you: Not urgent"; } Else if(iage>30) {Strsug+ = "Chico tell you: Get married soon!"; } Else{Strsug+ = "Chico tell you: Start looking for the object!"; }} mtxtr.settext (STRSUG); } };}
Android:id="@+id/txtr" /></linearlayout>
9-First App project