【问题标题】:Update listview - single row - chat from sqlite更新列表视图 - 单行 - 从 sqlite 聊天
【发布时间】:2014-06-07 12:13:16
【问题描述】:

如何更新列表视图中的一行(聊天)?

很容易制作 Customadapter = new (..),但如果我有 50000 条消息?制作 = new "Always" 非常慢

如何更新“x”行?

我尝试使用 adapterMessages.notifyDataSetChanged(); ,但不更新,这是正常的,我不知道我的列表视图中的行

例子:

user1 : hi
                 user2 : hi? (update here) row "x"
user1: is hello
                 user2: aa ok (update here) row "x"

我使用适配器更新列表视图,(消息接收或不接收) http://fielinks.com/sites/default/files/styles/large/public/images/double-check-whatsapp.jpg?itok=qBI0LGQL

【问题讨论】:

标签: android listview android-listview android-sqlite


【解决方案1】:
listview = (ListView)rootView.findViewById(R.id.listView1);
          listData= getCallDetails();


         listview.setAdapter(new CustomAdapter(getActivity().getBaseContext(),listData));

 listview.setOnItemClickListener(new  OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int positionToRemove,
                        long arg3) {
    updateFromDb(Id);
    listData.remove(positionToRemove);
    adapter.notifyDataSetChanged();
    }

【讨论】:

  • 我在 listData.remove,"stackoverflow.com/questions/18403647/…" 中没有访问权限,但我可以放入我的 customAdapter .remove,但如何获取 id ?我可以比较而不是位置“文本”?
  • setAdapter(new CustomAdapter(..) 我试过了,我的 eclipse 调试器显示,加载所有消息,你认为,15.000 条消息 + 总是更新,listivew = 慢,而不是点击,来自 sqlite ...,我需要找到我的列表视图的位置并修改,但 findPostionText 需要,例如:Hello 12:00h = hello 12:00h == true modify new text ..
  • 然后尝试使用listData.get(positionToRemove);稍后修改
  • 反正我很困惑,我不确定你想要什么
  • listData.get(messagText == position = true ) = true 我该怎么做?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-16
  • 1970-01-01
  • 2021-05-26
  • 1970-01-01
  • 1970-01-01
  • 2018-11-13
  • 1970-01-01
相关资源
最近更新 更多