Я пытаюсь использовать относительный макет в своем приложении. С двумя TextViews и кнопкой. Вот xml-файл:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:padding="30dip"
android:orientation="vertical">
<TextView
android:id="@+id/up"
android:text="@string/start_game"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<TextView
android:id="@+id/level"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@id/up"/>
/>
<Button android:id="@+id/start"
android:text = "@string/go"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Теперь TextView с id=up отображается отлично. Для второго TextView (с id = level) я хочу добавить к нему текст с помощью моего java-кода. Вот что я сделал:
TextView text = (TextView) findViewById(R.id.level);
text.setText("Hello Android");
Но это вылетает из программы. В чем здесь моя ошибка?
setContentView
. - person Cristian   schedule 20.03.2012