Attach items to a listview

A listview shows data provided by an adapter. To create a simple list use the following:

//Find the listview with id 'list' in the resources 
ListView listView = (ListView) findViewById(R.id.list);

//Make a connection through an adapter 
listView.setAdapter(new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, new String[] {"AAA", "BBB", "CCC"}));


Leave a Reply

Your email address will not be published. Required fields are marked *