class MyAdapter extends ArrayAdapter {
public MyAdapter(Context context, int resource) {
super(context, resource);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view=null;
if(convertView==null){
LayoutInflater inflater= (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.item,null);
}else {
view=convertView;
}
ImageView iv=(ImageView)view.findViewById(R.id.imageView);
TextView tv= (TextView) view.findViewById(R.id.textView);
iv.setImageResource(imgs[position]);
tv.setText(names[position]);
return view;
}
}
運行到加黑的getCount的時候程序就會崩潰,編程小白,望指教
http://blog.csdn.net/tianyaleixiaowu/article/details/50736488 看看自定義adapter怎麼做