Android: черный экран вместо новой активности - PullRequest
0 голосов
/ 29 мая 2011

Я вызываю новую активность в моем приложении для Android:

Intent intent = new Intent();   
intent.setClass(getApplicationContext(), UserInfo.class);
startActivity(intent);

В новом действии я вызываю setContentView как обычно:

public void OnCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.userfill);

Однако я вижу только черный экран с ярлыком активности в заголовке!

Файл манифеста содержит

<activity
  android:name=".UserInfo"
  android:label="@string/title_fill">
</activity>

userfill.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/MainLinearLayout">
    <TableLayout android:layout_height="wrap_content" android:id="@+id/tableLayout" android:layout_width="match_parent">
        <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow1" android:layout_weight="1" android:layout_width="match_parent">
            <AutoCompleteTextView android:layout_height="70dip" android:text="@string/enterTeg" android:id="@+id/autoCompleteTextView1" android:layout_width="match_parent"></AutoCompleteTextView>
        </TableRow>
        <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow2" android:layout_weight="1" android:layout_width="match_parent">
            <AutoCompleteTextView android:layout_height="70dip" android:layout_width="match_parent" android:text="@string/enterTeg" android:id="@+id/autoCompleteTextView2"></AutoCompleteTextView>
        </TableRow>
        <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow3" android:layout_weight="1" android:layout_width="match_parent">
            <AutoCompleteTextView android:layout_height="70dip" android:layout_width="match_parent" android:text="@string/enterTeg" android:id="@+id/autoCompleteTextView3"></AutoCompleteTextView>
        </TableRow>
        <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_weight="1">
            <ListView android:layout_height="wrap_content" android:id="@+id/listTimes" android:layout_width="match_parent"></ListView>
        </TableRow>
        <TableRow android:id="@+id/tableRow5" android:layout_height="match_parent" android:layout_weight="1" android:layout_width="match_parent" android:orientation="horizontal">
            <Button android:id="@+id/button1" android:layout_height="wrap_content" android:text="@string/btnOK" android:layout_weight="1" android:layout_width="150dip"></Button>
            <Button android:id="@+id/button2" android:layout_height="wrap_content" android:text="@string/btn_cancel" android:layout_weight="0" android:layout_width="160dip"></Button>
        </TableRow>
    </TableLayout>
</LinearLayout>

Почему я не вижу все элементы управления? В Graphical Layout все в порядке.

Ответы [ 2 ]

5 голосов
/ 29 мая 2011

Имя onCreate -метода начинается со строчной буквы.

Кроме того, нет необходимости определять layout_width или layout_height в TableRow:

Дети TableLayout не могут укажите атрибут layout_width. Ширина всегда MATCH_PARENT. Тем не мение, атрибут layout_height может быть определяется ребенком; значение по умолчанию ОБЕРНУТЬ СОДЕРЖИМОЕ. Если ребенок TableRow, то высота всегда WRAP_CONTENT.

См. здесь .

0 голосов
/ 29 мая 2011

В макете таблицы вместо wrap_content попробуйте match_parent

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...