Last active
August 29, 2015 14:16
-
-
Save arod2634/c206958e3c05dd67ddc1 to your computer and use it in GitHub Desktop.
Android 100 Exercise 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:weightSum="1"> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="10dp" | |
android:layout_marginBottom="10dp" | |
android:layout_marginLeft="10dp" | |
android:text="Please enter your information:" | |
android:id="@+id/introLabel" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="First Name:" | |
android:id="@+id/firstName" | |
android:layout_below="@+id/introLabel" | |
android:layout_alignLeft="@+id/introLabel" | |
android:layout_marginBottom="10dp" | |
android:layout_marginTop="10dp" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Last Name:" | |
android:id="@+id/lastName" | |
android:layout_below="@+id/firstName" | |
android:layout_alignLeft="@+id/firstName" | |
android:layout_marginBottom="10dp" | |
android:layout_marginTop="10dp" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Address:" | |
android:id="@+id/address" | |
android:layout_below="@+id/lastName" | |
android:layout_alignLeft="@+id/lastName" | |
android:layout_marginBottom="10dp" | |
android:layout_marginTop="10dp" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="City" | |
android:id="@+id/city" | |
android:layout_below="@+id/address" | |
android:layout_alignLeft="@+id/address" | |
android:layout_marginBottom="10dp" | |
android:layout_marginTop="10dp" /> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="State:" | |
android:id="@+id/state" | |
android:layout_below="@+id/city" | |
android:layout_alignLeft="@+id/city" | |
android:layout_marginBottom="10dp" | |
android:layout_marginTop="10dp" /> | |
<EditText | |
android:layout_width="200dp" | |
android:layout_height="wrap_content" | |
android:id="@+id/editFirstName" | |
android:layout_below="@+id/introLabel" | |
android:layout_toRightOf="@+id/firstName" | |
android:layout_marginLeft="25dp" /> | |
<EditText | |
android:layout_width="200dp" | |
android:layout_height="wrap_content" | |
android:id="@+id/editLastName" | |
android:layout_above="@+id/address" | |
android:layout_alignLeft="@+id/editFirstName" /> | |
<EditText | |
android:layout_width="200dp" | |
android:layout_height="wrap_content" | |
android:id="@+id/editAddress" | |
android:layout_below="@+id/editLastName" | |
android:layout_alignLeft="@+id/editLastName" /> | |
<EditText | |
android:layout_width="200dp" | |
android:layout_height="wrap_content" | |
android:id="@+id/editCity" | |
android:layout_below="@+id/address" | |
android:layout_alignLeft="@+id/editAddress" /> | |
<EditText | |
android:layout_width="200dp" | |
android:layout_height="wrap_content" | |
android:id="@+id/editState" | |
android:layout_below="@+id/editCity" | |
android:layout_alignLeft="@+id/editCity" /> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Save" | |
android:id="@+id/saveButton" | |
android:layout_below="@+id/editState" | |
android:layout_alignRight="@+id/editState" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void showUserData(View view) { | |
EditText firstName = (EditText) findViewById(R.id.editFirstName); | |
EditText lastName = (EditText) findViewById(R.id.editLastName); | |
EditText address = (EditText) findViewById(R.id.editAddress); | |
EditText city = (EditText) findViewById(R.id.editCity); | |
EditText state = (EditText) findViewById(R.id.editState); | |
TextView yourInfo = (TextView) findViewById(R.id.yourInfo); | |
yourInfo.setText("Your name is " + firstName.getText() + " " + lastName.getText() + "\nYou live at " + address.getText() + " " + city.getText() + " " + state.getText()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment