ArrayList myList = new ArrayList();
ListView listView = (ListView) findViewById(R.id.list);
ArrayAdapter adapter = new
Here's a quick and dirty example of how to use an ArrayAdapter if you don't want to bother yourself with extending the mother class:
class MyClass extends Activity {
private ArrayAdapter mAdapter = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
mAdapter = new ArrayAdapter(getApplicationContext(),
android.R.layout.simple_dropdown_item_1line, android.R.id.text1);
final ListView list = (ListView) findViewById(R.id.list);
list.setAdapter(mAdapter);
//Add Some Items in your list:
for (int i = 1; i <= 10; i++) {
mAdapter.add("Item " + i);
}
// And if you want selection feedback:
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
//Do whatever you want with the selected item
Log.d(TAG, mAdapter.getItem(position) + " has been selected!");
}
});
}
}