简体   繁体   中英

Two columns in from[ ] , one column in to[]

I have next problem. I have three columns in DB (id integer, picture_int integer(picture from resourse), picture_galery( path) and I want to set images from DB in listview. I want to check, if column picture_int is null, set image from column picture_galery and if picture_int!=null then set this picture. Sory for my english=(

You can use a Custom adapter by extending a BaseAdapter and overriding the required methods

 public int getCount() {
   return somevalie;
  }

  @Override
  public Object getItem(int arg0) {
  return arg0;
 }

  @Override
  public long getItemId(int arg0) {
   return arg0;
 }

  @Override
  public View getView(int arg0, View arg1, ViewGroup arg2) {

return view
}

For more info look at Custom Adapter Sample

and later create the database which you can access for setting the images to the custom list view. suppose consider like

if(theFieldYouAccess == null)
{
 //Do what you want
}
else
{
 //Do what you want
}

In the getView() functionality

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM