Eli Blokh
Eli Blokh

Reputation: 12293

Android: black screen instead of new activity

I invoke new activity in my Android application:

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

In new activity I call setContentView as usual:

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

However I see only black screen with activity label in the header!

Manifect file contains

<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>

Why I don't see all the controls?In Graphical Layout it's all right.

Upvotes: 0

Views: 1953

Answers (2)

Lukas Knuth
Lukas Knuth

Reputation: 25755

The onCreate-methods name starts with lower case.

Also, it's unnecessary to define a layout_width or layout_height in a TableRow:

The children of a TableLayout cannot specify the layout_width attribute. Width is always MATCH_PARENT. However, the layout_height attribute can be defined by a child; default value is WRAP_CONTENT. If the child is a TableRow, then the height is always WRAP_CONTENT.

See here.

Upvotes: 5

sat
sat

Reputation: 41076

In the table layout , instead of wrap_content, try match_parent

Upvotes: 0

Related Questions