My question here's that, I'm developing a small quiz so that I would like a picture at the very top and it is answer right below it. This really is all completed in a brand new activity where I wish to show the solutions for that quiz. You will find about 40 questions each by having an image. Hence, I attempted using HashMap the following:-

   ListView lv = (ListView)findViewById(R.id.list1);
   String[] from = new String[] {"ques","ans"};
   int[] to = new int[] {R.id.ques, R.id.ans};

           // prepare the list of all records
    List<HashMap<String,Bitmap>> fillMaps = new ArrayList<HashMap<String,Bitmap>>();
     Cursor c1 = db.getQues(4);
     byte[] bb = c1.getBlob(0);
     Bitmap image = BitmapFactory.decodeByteArray(bb, 0, bb.length);
     //Cursor c2 = db.getAns(4);
    // String ans1 ="Ans"+") "+c2.getString(0);
     HashMap<String,Bitmap> map = new HashMap<String, Bitmap>();
    // HashMap<String,String> map1 = new HashMap<String, String>();
     map.put("ques",image);
    // map1.put("ans",ans1);
     fillMaps.add(map);      

     SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.itemsign, from, to);
     lv.setAdapter(adapter);

However I could not try to properly implement it. This code doesn't work. It simply shows an empty page. So, any assistance will greatly be appreciated. Like me a new comer to android so be more in depth while explaining.

Well, I do not believe that the blob is the problem. This is actually the javadoc for that SimpleAdapter constructor:

public SimpleAdapter (Context context, List> data, int resource, String[] from, int[] to)

Since: API Level 1 Constructor Parameters

  • context The context in which the View connected with this particular SimpleAdapter is running
  • data A Listing of Maps. Each entry within the List matches one row within the list. The Maps retain the data for every row, and really should include all of the records specified by "from"
  • resource Resource identifier of the view layout that defines the sights with this list item. Design file will include a minimum of individuals named sights defined in "to"
  • from A listing of column names that'll be put into the Map connected with every item.
  • into the sights which should display column within the "from" parameter. These really should be TextViews. The very first N sights within this list receive the values from the first N posts within the from parameter.

You cannot use Bitmaps inside a SimpleAdapter, it's too simple for your :)