9-First App project

Source: Internet
Author: User

<?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

Related Article

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: info-contact@alibabacloud.com 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.