Creating A Custom Adapter

To use an Adapter with a ListView you must first extends an Adapter.

 class MyAdapter extends BaseAdapter {

Create a List member for the data container.

List<String> m_data = ArrayList<String>();

m_data will contain all string items that you will want to be displayed in the ListView. So in our constructor we will populate m_data with the strings we want to be shown.

 public MyAdapter() {
 m_data.add("item 1");
 m_data.add("item 2");
 m_data.add("item 3");
 }

Continue reading