当用户单击列表项时,我想开始另一个活动。当我运行此程序时,虚拟机上没有出现错误,但我的屏幕完全空白。关于我的代码有什么错误的任何建议?

我计划开始其他活动的活动代码是

public class Selector extends ListActivity {

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

    ListView listView = (ListView) findViewById(android.R.id.list);
     // storing string resources into Array
    String[] story_titles = getResources().getStringArray(R.array.story_list);

    // Binding resources Array to ListAdapter

    ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,android.R.layout.simple_list_item_1,android.R.id.text1,story_titles);

    listView.setAdapter(adapter);
}


        public void onListItemClick(ListView parent,View view, int position, long id) {


            // Launching new Activity on selecting single List Item
            Intent i = new Intent(this, Descriptor.class);
            // sending data to new activity
            startActivity(i);
        }





@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}


}

Descriptor类的代码如下

public class Descriptor extends ListActivity {

public void onCreateBundle(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.descriptor);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

}


描述符xml是

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >



<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="40dip"
    android:text="@string/select"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@android:color/background_dark" >
    </TextView>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >




<ListView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/list"
    android:layout_width="480dp"
    android:layout_height="wrap_content"
    android:padding="40dip"
    android:textSize="16dip"
    android:textStyle="bold" >

</ListView>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="40dip"
    android:text="@string/description"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@android:color/background_dark" >
    </TextView>

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Story Description goes Here"
    android:padding="40dip"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@android:color/background_dark"
   />

</LinearLayout>
</LinearLayout>
</LinearLayout>


清单是

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.fableoid"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".Selector" />
    <activity android:name=".Descriptor" />
</application>

</manifest>

最佳答案

您的Descriptor.class中的方法错误。

public void onCreateBundle(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.descriptor);
}


呼叫

public void onCreate(Bundle savedInstanceState)


代替

10-01 14:40