Mobile App Dev 2021W: Tutorial 5: Difference between revisions
Created page with "==Code== ===res/values/strings.xml=== <syntaxhighlight lang="xml" line> <resources> <string name="app_name">Temperature Converter</string> <string name="message">Ent..." |
|||
Line 1: | Line 1: | ||
==Code== | ==Code== | ||
===res/layout/activity_main.xml=== | |||
<syntaxhighlight lang="xml" line> | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
tools:context=".MainActivity"> | |||
<LinearLayout | |||
android:orientation="vertical" | |||
android:padding="10sp" | |||
android:gravity="center" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<EditText | |||
android:id="@+id/editTemperature" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:ems="10" | |||
android:gravity="center" | |||
android:hint="Enter Farenheit" | |||
android:inputType="numberSigned" /> | |||
<TextView | |||
android:id="@+id/result" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="@string/message" | |||
android:textAppearance="@style/TextAppearance.AppCompat.Large" /> | |||
</LinearLayout> | |||
</androidx.constraintlayout.widget.ConstraintLayout> | |||
</syntaxhighlight> | |||
===res/values/strings.xml=== | ===res/values/strings.xml=== |
Revision as of 21:56, 26 February 2021
Code
res/layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:orientation="vertical"
android:padding="10sp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/editTemperature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="Enter Farenheit"
android:inputType="numberSigned" />
<TextView
android:id="@+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/message"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
res/values/strings.xml
<resources>
<string name="app_name">Temperature Converter</string>
<string name="message">Enter a number please</string>
</resources>