AnnBnnCnnD 2013-03-04 03:21 采纳率: 0%
浏览 2273

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条回答

  • balmy 2013-03-04 03:53
    关注
    setListAdapter(new ArrayAdapter<String>(this,    android.R.layout.simple_list_item_1)),这句话里你的数据是不是根本没加上去?
    
    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?