2011-06-23 8 views
0

こんにちは、私はsdカードからのイメージでGridViewをバインドしたいのですが、res/drawableフォルダにはバインドしませんか?以下 は、私は解像度の画像を使用していますコード/描画可能なフォルダです // RICE //外部画像を使用したAndroid Bind GridView?

public static int[] mPictureIds_rice = { 
      R.drawable.chinese_fried_rice, R.drawable.nasi_goreng }; 
    public static String[] mPrice_rice_detl = { "seafood   \tRs. 725\nprawn    \tRs. 675\nfish     \tRs. 375\nchicken   \tRs. 275\nvegetables\t  Rs. 225\negg     \tRs. 195", 
    "Rs. 375.00" }; 
    public static String[] mPrice_rice = { "225.00", "375.00" }; 
    public static String[] mName_rice_detl = { "chinese fried rice (chinese)", 
      "nasi goreng (indonesia)" }; 
    public static String[] mName_rice = { "chinese fried rice", 
     "nasi goreng" }; 
    public static String[] mName_rice_desc = { 
      "Wok tossed rice grains, assortment of vegetarian and non-vegetarian selection", 
      "Indonesian style fried rice with assorted seafood,meat and vegetable", }; 
    public static int[] mVegNon_rice = { R.drawable.vegicon, 
      R.drawable.non_veg }; 
    // // 

** 以下である私のGridViewのためのコード **

GridView gridview_rice = (GridView) findViewById(R.id.gridview_beverages); 
     gridview_rice.setAdapter(new ImageAdapter(this, 
       mPictureIds_rice, mName_rice, mPrice_rice)); 
     gridview_rice.setOnItemClickListener(new OnItemClickListener() { 
      public void onItemClick(AdapterView<?> parent, View v, 
        final int position, long id) { 

       Intent intent1 = new Intent(getApplicationContext(), 
         view_beverages_detail.class); 
       intent1.putExtra("position", position); 
       intent1.putExtra("Image", mPictureIds_rice); 
       intent1.putExtra("ImageName",mName_rice_detl); 
       intent1.putExtra("ImageNameShort",mName_rice); 
       intent1.putExtra("VegNonVegImage", mVegNon_rice); 
       intent1.putExtra("ItemDescription",mName_rice_desc); 
       intent1.putExtra("ItemPrice",mPrice_rice); 
       startActivity(intent1); 
      } 
     }); 

私はwebserviceから画像を取得しているし、フォルダーの下にアンドロイドデバイスに入れてthatsなぜ私が欲しいの理由BIDD GRIDVIEWは、デバイスに保存されている画像から?

答えて

0

私はXYZパスにabc.png画像を保存する場合は、イメージの絶対パスが

String absPathOfImage = Environment.getExternalStorageDirectory()+"/xyz/"+abc.png 

のいずれかString[] mPictureIds_riceint[] mPictureIds_riceを置き換えることになるそのabsolutepath 例を使用して、SDカードから画像を取得することができますまたは配列リストを

public static String[] mPictureIds_rice = { 
      abspathOfImg1, R.drawable.nasi_goreng }; 

又は

public static ArrayList<String> mPictureIds_rice = new ArrayList<String>(); 

sdカードに保存した後の画像の絶対パスを追加

+0

ありがとうございます、本当にありがとうございます – PCS

関連する問題