Skip to content Skip to sidebar Skip to footer

Android Listview Refresh

In my app when user clicks on the ADD menu button, a listview appears populated with items that are loaded from a text file. So now user can add one more item to the listview. Afte

Solution 1:

Found the solution: I had to redeclare lv1 = (ListView) findViewById(R.id.ListView01); I don't the reason behind this, but it cost me 4 hours to find this out.

if (fileisempty == false)
              {
                  adapter1.clear();
                  adapter1.notifyDataSetChanged();
                  lv1 = (ListView) findViewById(R.id.ListView01);
                  ArrayAdapter<String> adapter11;
                  adapter11 = new ArrayAdapter<String>(Connection.this,R.layout.list_black_text,R.id.list_content, assignArr00);
                  lv1.setAdapter(adapter11);
                  adapter11.notifyDataSetChanged();

              }
              else
              {
                  lv1 = (ListView) findViewById(R.id.ListView01);
                  ArrayAdapter<String> adapter11;
                  adapter11 = new ArrayAdapter<String>(Connection.this,R.layout.list_black_text,R.id.list_content, assignArr00);
                  lv1.setAdapter(adapter11);
                  adapter11.notifyDataSetChanged();
              }

Post a Comment for "Android Listview Refresh"