Я пишу приложение для Android и в нем хочу иметь своего рода заголовок, включающий название игры, оценку и т. Д. Затем ниже этого я хочу иметь сетку изображений, которая будет напоминать плитки, на которых я могу отображать разные символы в своей игре.Формат Android не отображается должным образом
У меня есть следующий макет XML, но когда я запускаю его, и я получаю черный экран:
<LinearLayout xmlns:android="http://schemas.android.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 инициализируется в этом учебнике:
http://developer.android.com/resources/tutorials/views/hello-gridview.html
т.е. , в моей основной деятельности onCreate():
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
Может ли кто-нибудь увидеть что-нибудь, что я сделал неправильно?
Спасибо!
Спасибо за ответ, я был просто глупым и имел свою начальную форму в игре onCreate(), но макет не отображался до тех пор, пока onCreate() не догадался? В любом случае, решив сделать мой класс с игровым циклом Runnable – Kalypso
@Kalypso: Правильно - пока вы не вернете управление Android, ваш пользовательский интерфейс не будет отображаться. – CommonsWare