protected class MyArrayAdapter extends ArrayAdapter<E>
{
//List of Events
private ArrayList<E> myList;
/*
* Creates the Adapter for the list
*/
public MyArrayAdapter (Context context, int textViewResourceId, ArrayList<E> list)
{
super(context, textViewResourceId, list);
myList= list;
}
/**
* inflate view for each row
*/
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
// if the given channel row view is not being updated
if (v == null)
{
// inflate you linear
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.channel_list_row, null,false);
}
// edit view here, as shown below
TextView topTextView = (TextView)v.findViewById(R.id.mytextview);
...
// return the view for the given position
return v;
}
}
而且在主代碼
// create the array adapter
myArrayAdapter = new MyChannelAdapter(Activity Cntext, Custom row layout, lList);
// bind the array adapter to the list view
ListView.setAdapter(myArrayAdapter);
我猜你正在尋找定製適配器 – Raghunandan