protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//use ArrayAdapter
lv_list = (ListView) findViewById(R.id.lv_list);
initDataList();
Log.e(TAG, "will new adapter");
adapter = new MyAdapter(this, R.layout.list_item, datalist);
//adapter = new MyAdapter(this, R.layout.list_item, 0);
Log.e(TAG, "new adapter done");
lv_list.setAdapter(adapter);
}
private void initDataList() {
datalist = new ArrayList<>();
for (int i = 1; i < 10; i++){
Fruit fruit = new Fruit();
fruit.imgId = R.drawable.adc;
fruit.name = "lyl" + i;
datalist.add(fruit);
}
}
class MyAdapter extends ArrayAdapter<Fruit>{
private int resourceId;
private Context myContext;
private ViewHolder holder;
// public MyAdapter(Context context, int resource, int textViewResourceId) {
// super(context, resource, textViewResourceId);
// resourceId = resource;
// }
public MyAdapter(Context context, int textViewResourceId, List<