Professional Documents
Culture Documents
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
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=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
android:id="@+id/linearLayout1">
<EditText
android:id="@+id/editText_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:hint="@string/hint_name"/>
<EditText
android:id="@+id/editText_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:hint="@string/hint_phonenumber"/>
<Spinner
android:id="@+id/label_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Spinner>
<CheckBox
android:id="@+id/cb_family"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_family"/>
<CheckBox
android:id="@+id/cb_friends"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_friends"/>
<RadioGroup
android:id="@+id/rgSim"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton
android:id="@+id/rg1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_sim1"/>
<RadioButton
android:id="@+id/rg2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_sim2"/>
</RadioGroup>
<Button
android:id="@+id/button_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="launchSecondActivity"
android:text="@string/show_button"
android:drawableLeft="@drawable/ic_button_save"/>
</LinearLayout>
</RelativeLayout>
activity_second.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
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=".SecondActivity">
<TextView
android:id="@+id/text_header_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:text="@string/text_header_name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
<TextView
android:id="@+id/result_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_toRightOf="@+id/text_header_name"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="@+id/text_header_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_header_name"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:text="@string/text_header_phone"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
<TextView
android:id="@+id/result_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_header_name"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_toRightOf="@+id/text_header_phone"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="@+id/text_header_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_header_phone"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:text="@string/text_header_type"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
<TextView
android:id="@+id/result_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_header_phone"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_toRightOf="@+id/text_header_type"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="@+id/text_header_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_header_type"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:text="@string/text_header_group"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
<TextView
android:id="@+id/result_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_header_type"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_toRightOf="@+id/text_header_group"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="@+id/text_header_sim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_header_group"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:text="@string/text_header_sim"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
<TextView
android:id="@+id/result_sim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_header_group"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_toRightOf="@+id/text_header_sim"
android:textAppearance="?android:attr/textAppearanceMedium"/>
</RelativeLayout>
dimens.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
strings.xml
<resources>
<string name="app_name">User Input Control_PM13</string>
<string name="app_name2">Output</string>
<string name="phonenumber_label">"Phone Number : "</string>
<string-array name="label_array">
<item>Home</item>
<item>Work</item>
<item>Mobile</item>
<item>Other</item>
</string-array>
<string name="spinner_work">Home</string>
<string name="hint_name">Name</string>
<string name="hint_phonenumber">Phone Number</string>
<string name="label_friends">Friends (Group)</string>
<string name="label_family">Family (Group)</string>
<string name="label_sim1">SIM 1</string>
<string name="label_sim2">SIM 2</string>
<string name="show_button"> Save</string>
<string name="nothing_entered">Nothing Entered.</string>
<string name="nothing_selected">"onNothingSelected: "</string>
<string name="text_header_name">Name : </string>
<string name="text_header_phone">Phone : </string>
<string name="text_header_type">Type : </string>
<string name="text_header_group">Group : </string>
<string name="text_header_sim">SIM Type : </string>
</resources>
MainActivity.java
package com.example.morefast.userinputcontrol_pm13;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.content.Intent;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Spinner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SecondActivity.java
package com.example.morefast.userinputcontrol_pm13;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</manifest>