Android layout not showing properly
I'm writing an android app and in it I want to have a sort of title bar including the name of the game, the score, and things like that. Then below that I want to have an grid of image views, which will kind of be like tiles on which I can display different characters in my game.
I have the following xml layout, but when I run it and I get a black screen:
<LinearLayout xmlns:android="http://schemas.an开发者_如何转开发droid.com/apk/res/android" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
    <TextView android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="@string/app_name"
            />
    <TextView android:id="@+id/score"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="@string/score"
            />
    <TextView android:id="@+id/score"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="0"
            />
    <TextView android:id="@+id/robotsLeft"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="@string/robots"
            />
    <TextView android:id="@+id/score"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="0"
            />
</LinearLayout>
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gridview"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:columnWidth="90dp"
    android:numColumns="auto_fit"
    android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp"
    android:stretchMode="columnWidth"
    android:gravity="center"
/>
GridView is initialized as per this tutorial:
http://developer.android.com/resources/tutorials/views/hello-gridview.html
ie. in my main activity's onCreate():
super.onCreate(savedInstanceState);  
setContentView(R.layout.main);          
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
Can anyone see anything I've done wrong?
Thanks!
Well, that's invalid XML, because there's no root element. Also, all of your TextView widgets have android:layout_height="fill_parent", which is rather strange. You might also consider using hierarchyviewer to examine your layout more closely and see what else may be going wrong.
you should put a (linear)layout underneath them, as your xml is invalid.
 加载中,请稍侯......
      
精彩评论