Difference between revisions of "Dynamic List Activity"
From John Freier
(Created page with 'package com.johnfreier.dailyfactorcrap; import java.util.ArrayList; import com.johnfreier.utilities.URLUtils; import android.app.ListActivity; import android.app.ProgressDialo…') |
|||
Line 1: | Line 1: | ||
− | |||
− | + | public class TopActivity extends ListActivity | |
+ | { | ||
+ | private ArrayAdapter<String> adapter; | ||
+ | private ArrayList<String> list; | ||
− | + | public void onCreate(Bundle savedInstanceState) | |
+ | { | ||
+ | super.onCreate(savedInstanceState); | ||
− | + | this.list = new ArrayList<String>(); | |
− | + | adapter = new ArrayAdapter<String>(this, R.layout.top, this.list); | |
− | + | setListAdapter(adapter); | |
− | + | ||
− | + | ||
− | + | //not for sure if I need the below. | |
− | + | //ListView lv = getListView(); | |
− | + | //lv.setTextFilterEnabled(true); | |
− | + | ||
− | + | ||
− | + | ||
+ | addItem(); | ||
− | + | } | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | public void addItem() | |
− | + | { | |
− | + | this.list.add("Two"); | |
− | + | adapter.notifyDataSetChanged(); | |
− | + | } | |
− | + | } | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | } | + |
Revision as of 09:37, 2 February 2011
public class TopActivity extends ListActivity { private ArrayAdapter<String> adapter; private ArrayList<String> list;
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
this.list = new ArrayList<String>(); adapter = new ArrayAdapter<String>(this, R.layout.top, this.list); setListAdapter(adapter);
//not for sure if I need the below. //ListView lv = getListView(); //lv.setTextFilterEnabled(true);
addItem();
}
public void addItem() { this.list.add("Two"); adapter.notifyDataSetChanged(); } }