0

我的班级中有一个列表视图和适配器,我正在从另一个活动向 db 插入一些值。然后我想将这些值检索到标签页中的列表中。

当我正常运行时,我遇到了异常,我检查了我的代码并且找不到任何错误。

但是,当我在调试模式下运行时,它可以完美运行。

这里有什么问题?

我的示例代码如下

db = new DatabaseHandlerOn(getApplicationContext());
m_results = new ArrayList<On>();
this.m_adapter = new PlayedOn(this, R.layout.playedrowon, m_results);
this.setListAdapter(this.m_adapter);

sendNumbers2 = new Runnable() {
    @Override
    public void run() {
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
        Date date = new Date();
            /*for(int i=15;i<55;i++)
            {
            db.addContact(new OnNumara(i+"","555",dateFormat.format(date),"1","2","2","2","2","2","2","2","2","2","2","2",
                    "2","2","2","2","2","2","2","2","2","2","55555555","0","0"));
            }*/
        playedOn = db.getAllContacts();

        for (On on : played) {
            m_results.add(on);
        }
        handler.sendEmptyMessage(0);
    }
};
Thread thread = new Thread(sendNumbers2, "sendNumbers2");
thread.start();

m_ProgressDialog = ProgressDialog.show(PlayedOnActivity.this,
        "", getString(R.string.PleaseWait), true);
m_ProgressDialog.setCancelable(true);

handler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        m_ProgressDialog.dismiss();
        m_adapter.notifyDataSetChanged();
    }
};

日志:

11-05 14:10:03.839: E/AndroidRuntime(15958): java.lang.NullPointerException

不明白有没有空指针异常,debug模式下也应该给出。

4

0 回答 0