[Android]simplelistadapter 与数据库绑定显示list 并且根据数据库内容产生图片信息

 

主要是重写  simplelistadapter这个类  内部的bindview这个函数来调整图片的显示,记下这个随笔以便以后查看

public class TuanAdapter extends SimpleCursorAdapter{

public TuanAdapter(Context context, int layout,Cursor cursor,String[] from, int [] to ){ super (context,layout,cursor,from,to);}

@Override
public void bindView(View view, Context context, Cursor cursor) {
// TODO Auto-generated method stub
super .bindView(view, context, cursor);
RelativeLayout rl
= (RelativeLayout)view;
ImageView myimageview
= (ImageView)rl.findViewById(R.id.titleimage);

String sitename
= cursor.getString(cursor.getColumnIndex( " sitename " ));
if (sitename.equals( " 拉手 " )){
myimageview.setBackgroundResource(R.drawable.lashouico);
}
else if (sitename.equals( " 美团 " )){
myimageview.setBackgroundResource(R.drawable.meituanico);
}
else if (sitename.equals( " 团宝网 " )){
myimageview.setBackgroundResource(R.drawable.tuanbaoico);
}
else if (sitename.equals( " 爱帮 " )){
myimageview.setBackgroundResource(R.drawable.aibangico);
}
else if (sitename.equals( " F团 " )){
myimageview.setBackgroundResource(R.drawable.ftuanico);
}
else if (sitename.equals( " 大众点评团 " )){
myimageview.setBackgroundResource(R.drawable.dianpingico);
}
else if (sitename.equals( " 满座 " )){
myimageview.setBackgroundResource(R.drawable.manzuoico);
}


}

你可能感兴趣的:(android)