First of all, I'm a newbie on Android programming, so please be detailed in your answers.
I have a layout main.xml file with format similar to
<?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 = "fill_parent">
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
androi开发者_JS百科d:orientation = "horizontal"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent">
<EditText
android:id="@+id/a"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/xSquared"
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:text = "@string/equationPart1"
/>
</LinearLayout>
<LinearLayout
...
</LinearLayout>
</LinearLayout>
In my Java source file, I inflate the UI using command: setContentView(R.layout.main);
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
However, when I run the emulator, the UI does not show up like what I expect. Instead, it just display a simple EditText text box.
I wonder what is going wrong. Is it because I put a layout inside another layout? I don't think there is any problem with that right?
In your main activity class change the class definition from extends ListActivity to extends Activity
精彩评论