【问题标题】:Android - empty items added to the listview?Android - 添加到列表视图的空项目?
【发布时间】:2011-04-05 08:30:05
【问题描述】:

我正在尝试将正在运行的任务添加到ListView

当我第一次使用名为loadTasks() 的函数添加时。它被完美地添加了。 但是当我尝试重新加载它时,因为我每 10 秒刷新一次任务列表,它会在我的列表中添加两个或更多空项目。

【问题讨论】:

  • 私有字符串[] SystemProcessList = {"system", "com.android.phone", "com.android.voicedialer", "com.android.mms", "com.android.media" , “com.android.calendar”, “com.android.alarmclock”, “com.android.inputmethod”, “android.process”, “com.google.process”, “:”};这是我用来避免系统进程的系统进程列表。

标签: android listview items


【解决方案1】:

尝试使用此代码重新加载列表

private Handler meethandler=new Handler()
    {
        public void handleMessage(Message msg) {
            ArrayAdapter aa=new ArrayAdapter<String>(HomeScreen.this,android.R.layout.test_list_item, mMeeting);
            mMeetinglist.setAdapter(aa);
            aa.notifyDataSetChanged();
            mMeetinglist.invalidate();              
        }

    };

当你想更新列表时,像这样调用处理程序

meethandler.sendemptymessage(0);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-11
    • 1970-01-01
    • 1970-01-01
    • 2020-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-29
    相关资源
    最近更新 更多