Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //not by me, but tested
- private ArrayList<String> titles;
- private MyListAdapter adapter;
- private ListView myListView;
- @Override
- public void onCreate(Bundle savedInstanceState){
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main_activity);
- myListView = (ListView) findViewById(R.id.my_list);
- titles = new ArrayList<String>()
- for(int i =0; i<20;i++){
- titles.add("Title "+i);
- }
- adapter = new MyListAdapter(this, titles);
- myListView.setAdapter(adapter);
- }
- @Override
- public void onResume(){
- super.onResume();
- // first clear the items and populate the new items
- titles.clear();
- for(int i =0; i<20;i++){
- titles.add("New Title "+i);
- }
- adapter.notifySetDataChanged();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement