2 annbnncnnd AnnBnnCnnD 于 2013.03.04 11:21 提问

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"};

@Override
protected 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(this,selected);
        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>

1个回答

baimy1985
baimy1985   2013.03.04 11:53
setListAdapter(new ArrayAdapter<String>(this,    android.R.layout.simple_list_item_1)),这句话里你的数据是不是根本没加上去?
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!