Android: Why my user Interface does not get drawn when I Inflate the resource layout file?

Posted by Einiosaurus on Stack Overflow See other posts from Stack Overflow or by Einiosaurus
Published on 2011-01-12T02:41:32Z Indexed on 2011/01/12 2:54 UTC
Read the original article Hit count: 242

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"
         android: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?

© Stack Overflow or respective owner

Related posts about android

Related posts about layout