2011-10-26 18 views
3

シンプルなアダプタを使用して画像をリストビューに設定すると少し問題があります。私はSQLiteのデータベースからIDを使用してSDカードから画像を取得していますので、sqliteのステートメントが働いている、画像がSDカード上にあるが、私は私のリストビューでそれらを設定しようとすると、それは私に出力を与えている:Android SimpleAdapter画像をリストビューに追加

resolveUri failed on bad bitmap uri: [email protected] 
LogCatの

ここで私はそれを行うために使用しているコードは次のとおりです。

String sqlite2 = "SELECT objectId FROM collectionmedias WHERE collectionId="+collId+" AND mediaType="+fronImage; 
      Cursor bg = userDbHelper.executeSQLQuery(sqlite2); 
      if (bg.getCount() == 0) { 
       Log.i("", "No Image file"); 
       bg.close(); 
      } else if (bg.getCount() > 0) { 
       for (bg.move(0); bg.moveToNext(); bg.isAfterLast()) { 

        objectId = Integer.parseInt(bg.getString(bg.getColumnIndex("objectId"))); 
        Log.i("","objectId : "+objectId); 
        path = Environment.getExternalStorageDirectory() 
          + "/.MyApp/MediaCollection/" + objectId + ".png"; 
        Log.v("","path: "+path); 

       } 
      } 

      BitmapFactory.Options options = new BitmapFactory.Options(); 
      options.inTempStorage = new byte[2*1024]; 

      Bitmap ops = BitmapFactory.decodeFile(path, options); 



      hm = new HashMap<String, Object>(); 
       hm.put(IMAGE, ops); 
       hm.put(TITLE, text); 
       hm.put(CARDS_COUNT, cardsCount +" MyApp"); 
       items.add(hm); 
     } 

     final SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.main_listview, 
       new String[]{TITLE, CARDS_COUNT, IMAGE}, new int[]{ R.id.main_name, R.id.main_info, R.id.main_img}); 
     listView.setAdapter(adapter); 

答えて

2

私はこれを使用してそれを修正:path = Environment.getExternalStorageDirectory() + "/MyApp/MediaCollection/" + objectId + ".png";

+1

私は同じ問題を持っていたが、私はダウンロード画像法の代わりに、ビットマップを使用するので、私の方法が若干異なっています工場。私の質問を見てください:http://stackoverflow.com/questions/13450432/using-simpleadapter-with-image-for-listview –

関連する問題