问题描述
- ListActivity无法显示
- 应用运行之后没有崩溃,但是什么也不显示,空白页。不知道问题出在哪里?
帮忙看一下,多谢。
package com.eric.thebasics;import android.app.ListActivity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.widget.ArrayAdapter;import android.widget.ListView;public class TutorialTwo extends ListActivity {String classNames[] = {""main""menu""Sweet""TutorialOne""};@Overrideprotected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter<String>(this android.R.layout.simple_list_item_1));}protected void onListItemClick(ListView lv View v int position long id){ super.onListItemClick(lv v position id); String openClass = classNames[position]; try{ Class selected = Class.forName(""com.eric.thebasics."" + openClass); Intent selectedIntent = new Intent(thisselected); startActivity(selectedIntent); }catch (ClassNotFoundException e){ e.printStackTrace(); }}}
button代码:
tut2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub buttonSound.start(); startActivity(new Intent(""com.eric.thebasics.TUTORIALTWO""));
manifest :
<activity android:name="".TutorialTwo"" android:label=""@string/app_name"" > <intent-filter> <action android:name=""com.eric.thebasics.TUTORIALTWO"" /> <category android:name=""android.intent.category.DEFAULT"" /> </intent-filter> </activity>
解决方案
setListAdapter(new ArrayAdapter<String>(this android.R.layout.simple_list_item_1))这句话里你的数据是不是根本没加上去?
时间: 2025-01-25 13:40:31