我的 ListAdapter 有问题。
我这样创建它:
public class MyAdapter extends BaseAdapter {
private List<Object> objects;
private final Context context;
public MyAdapter (Context context, List<Object> objects) {
this.context = context;
this.objects = objects;
}
public int getCount() {
return objects.size();
}
public Object getItem(int position) {
return objects.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
Object obj = objects.get(position);
tvRow = (TextView)findViewById(R.id.tvRow);
tvRow.setText(obj.toString());
Typeface typeface = Typeface.createFromAsset(getAssets(), "Fonts/DS-DIGIT.TTF");
tvRow.setTypeface(typeface);
return tvRow;
}
}
在使用我的 custom 之前ListAdapter
,我是这样使用它的:
private ArrayAdapter<String> m_lapList;
setListAdapter(new ArrayAdapter<String>(this, R.layout.laps_row));
m_lapList = (ArrayAdapter<String>)getListAdapter();
如何使用我的新 ListAdapter?