Basic LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</LinearLayout>
When this code is saved, the ADK will use the Android Asset Packaging Tool (AAPT) to generate R.java
In Android, a widget is called a View and a layout container like LinearLayout is called a ViewGroup. Above has created an empty ViewGroup
Asking a Question
In order to ask a question, we'll need to add a TextView to the top of the layout. To add this, put the following in between the LinearLayout element.
<TextView
android:id="@+id/question"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Please wait..."
/>
Now for the answers we're going to want multiple choices. If we use buttons for starters that'll do, but since we can't set a variable number of buttons we'll need to contain them. So let's create a new LinearLayout.
<LinearLayout
android:id="@+id/answers"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</LinearLayout>
Then, for each button we want something similar to this:
<Button
android:id="@+id/yes"
android:text="Yes!"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
No comments:
Post a Comment