android - Values are not Populating in Listview -


this question has answer here:

i trying develop android application can display values multiple tables.

i have used base adapter display values since need display queried values in list. when try display values in list view blank.

i not sure have done wrong.

i using below method query data database display required values.

  public cursor getassetinstore()     {          sqlitedatabase db_database = getreadabledatabase();          cursor c  = db_database.rawquery("select asset_name,warrenty,assetimage,asset_status `assets`,`aseetissued` assets.assetid = aseetissued.assetissuedid , asset_status =?" ,                 new string [] {"in storage"}, null);         return c;      } 

the below methods used populate values onto list view.

private void populateassetlistview()     {          cursor c = db_database.getassetinstore();         assetlistview.setadapter(new assetlistadapter(this, c));       }       public class assetlistadapter  extends baseadapter     {          private context mcontext;         cursor cursor;          public assetlistadapter(context context, cursor c) {             super();              mcontext = context;             cursor =c ;          }           @override         public int getcount() {             return 0;         }          @override         public object getitem(int position) {             return null;         }          @override         public long getitemid(int position) {             return 0;         }          @override         public view getview(int position, view view, viewgroup parent) {              layoutinflater inflater = (layoutinflater) mcontext.getsystemservice(context.layout_inflater_service);            //the layout assigned custome created created in case customeassetview cales displayed per list             view = inflater.inflate(r.layout.assetsinstore_placeholder, null);              cursor.movetoposition(position);              textview assetsstatus = (textview) view.findviewbyid(r.id.assetssatutsstore_view);             int status = cursor.getint(cursor.getcolumnindex("asset_status"));             assetsstatus .settext(string.valueof(status));              textview assetsname = (textview) view.findviewbyid(r.id.assetstore_name_view);             string assetname = cursor.getstring(cursor.getcolumnindex("asset_name"));             assetsname.settext(assetname);              textview warrenty = (textview) view.findviewbyid(r.id.assetstore_warrenty_view);             string custdesignation = cursor.getstring(cursor.getcolumnindex("warrenty"));             warrenty .settext(custdesignation);               imageview assetimage = (imageview) view.findviewbyid(r.id.list_image);              byte[] bb = cursor.getblob(cursor.getcolumnindex("assetimage"));             assetimage.setimagebitmap(bitmapconver.getphoto(bb));              return view;         }     } 

try use cursor adapter in place of base adapter. moreover, beware position you're passing cursor may not think.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -