简单列表适配器中的错误

时间:2011-11-11 15:50:44

标签: android

我正在尝试使用简单的列表适配器显示多个列表视图但我的应用程序在我要去的时候崩溃,这里的适配器是我的代码;

当我的程序崩溃

时,我的logcat视图就是这个
11-11 09:03:06.147: DEBUG/AndroidRuntime(789): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
    11-11 09:03:06.147: DEBUG/AndroidRuntime(789): CheckJNI is ON
    11-11 09:03:06.907: DEBUG/AndroidRuntime(789): Calling main entry com.android.commands.pm.Pm
    11-11 09:03:06.937: DEBUG/AndroidRuntime(789): Shutting down VM
    11-11 09:03:06.957: DEBUG/dalvikvm(789): GC_CONCURRENT freed 101K, 71% free 297K/1024K, external 0K/0K, paused 3ms+1ms
    11-11 09:03:06.957: DEBUG/dalvikvm(789): Debugger has detached; object registry had 1 entries
    11-11 09:03:06.987: INFO/AndroidRuntime(789): NOTE: attach of thread 'Binder Thread #3' failed
    11-11 09:03:07.547: DEBUG/AndroidRuntime(799): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
    11-11 09:03:07.547: DEBUG/AndroidRuntime(799): CheckJNI is ON
    11-11 09:03:08.267: DEBUG/AndroidRuntime(799): Calling main entry com.android.commands.am.Am
    11-11 09:03:08.307: INFO/ActivityManager(68): Force stopping package com.flds uid=10052
    11-11 09:03:08.307: INFO/Process(68): Sending signal. PID: 779 SIG: 9
    11-11 09:03:08.457: INFO/ActivityManager(68): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.flds/.TestssActivity } from pid 799
    11-11 09:03:08.487: DEBUG/AndroidRuntime(799): Shutting down VM
    11-11 09:03:08.507: DEBUG/dalvikvm(799): GC_CONCURRENT freed 102K, 69% free 322K/1024K, external 0K/0K, paused 1ms+2ms
    11-11 09:03:08.537: INFO/ActivityManager(68): Start proc com.flds for activity com.flds/.TestssActivity: pid=808 uid=10052 gids={}
    11-11 09:03:08.547: WARN/InputManagerService(68): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4059a5e8
    11-11 09:03:08.577: INFO/AndroidRuntime(799): NOTE: attach of thread 'Binder Thread #3' failed

public class TestssActivity extends Activity
{

    private SimpleAdapter mSchedule;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ListView list = (ListView) findViewById(R.id.SCHEDULE);

        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

        HashMap<String, String> map = new HashMap<String, String>();
        map.put("train", "101");
        map.put("from", "6:30 AM");
        map.put("to", "7:40 AM");
        mylist.add(map);


       mSchedule = new SimpleAdapter(this, mylist, R.layout.row,new String[] {"train", "from", "to"}, new int[] {R.id.TRAIN_CELL, R.id.FROM_CELL, R.id.TO_CELL});
       list.setAdapter(mSchedule);

    }

}

1 个答案:

答案 0 :(得分:0)

没有setContentView(...

找不到ListView,因为没有。

博客页面已删除。或错误的链接。