我的代码运行没有错误,但自定义 Listview 不显示值。
我的代码运行没有错误,但自定义 Listview 不显示值。
这是我的代码:
适配器
公共类适配器扩展 BaseAdapter{
ArrayList<mealItems> itemList;
public Activity context;
public LayoutInflater inflater;
public DiseasesAdapter(Activity context,int x,ArrayList<mealItems> itemList) {
super();
this.context = context;
this.itemList = itemList;
this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public Object getItem(int position) {
return itemList.get(position);
}
public long getItemId(int position) {
return 0;
}
public static class ViewHolder
{
ImageView img;
TextView Title;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if(convertView==null)
{
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.disease_row, null);
holder.Title = (TextView) convertView.findViewById(R.id.Name);
holder.img = (ImageView) convertView.findViewById(R.id.image);
convertView.setTag(holder);
}
else
holder=(ViewHolder)convertView.getTag();
Items bean = (Items) itemList.get(position);
holder.Title.setText(bean.getTitle());
holder.img.setImageResource(bean.getImage());
return convertView;
}
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
}