Clear Android ListView

后端 未结 4 850
别那么骄傲
别那么骄傲 2021-01-22 10:39

I have a ListView. I want to dynamically change the contents of the listview.I used \"adapter.notifyDataSetChanged();\" to change the contents. I have also tried setting the ada

相关标签:
4条回答
  • 2021-01-22 11:08

    remove adapter.notifyDataSetChanged(); hope it works

    0 讨论(0)
  • 2021-01-22 11:26

    If you use an ArrayAdapter instead of a SimpleAdapter you can call

    ArrayAdapter.clear();
    ArrayAdapter.notifyDataSetChanged();
    

    To remove all the elements from the adapter.

    0 讨论(0)
  • 2021-01-22 11:27

    Try This

    final Handler handler = new Handler();
                     handler.postDelayed( new Runnable(){
                            @Override
                            public void run(){
                     //this line i have added in your code
                             registeredList.clear();
                            accessWebService();
                            handler.postDelayed(this, 10 * 1000);
                            Log.i("TAG", "notify");
    
                     }
                            }, 10 * 1000
    
                            ); 
    
    0 讨论(0)
  • 2021-01-22 11:29

    Try this please:

    Clear the arraylist/HashMap

    Add new items

    adapter.notifyDataSetChanged();

    set adapter.

    0 讨论(0)
提交回复
热议问题