1

私の問題は

ディレクトリ内の画像ファイルへのパスを持つ文字列配列があります。スライドショーのように画像を表示する必要があります。私はImageFlipperとViewFlipperを調べてきました。

解決策を提供する方法として私に解決策を提供してください。画像をImageFlipperまたはViewFlipperに渡す方法。

前もって感謝します

4

1 に答える 1

1

私はそれを行う方法を理解することができました.....これは私のコードです

String[] paths={"/mnt/user/Pictures/IMG_5509_LRS.jpg",
                                  "/mnt/user/Pictures/IMG_6076_LRS.jpg",
                                                    "/mnt/user/Pictures/IMG_5790_LRS.jpg"};
        FileInputStream in;
        BufferedInputStream buf;
        ArrayList<Drawable> drawablesArray=new ArrayList<Drawable>();
        ArrayList<Bitmap> bitmapArray=new ArrayList<Bitmap>();
        File file = null;
        final ImageSwitcher imageswticher=(ImageSwitcher) findViewById(R.id.imageSwitcher1);
         for(int i=0;i<paths.length;i++)
         {
              try {
                in=new FileInputStream(paths[i]);
                buf=new BufferedInputStream(in);
                Bitmap bMap=BitmapFactory.decodeStream(buf);
                bitmapArray.add(bMap);

            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
              ImageView iv=(ImageView) findViewById(R.id.imageView1);

              ImageSwitcher imageswitcher=(ImageSwitcher) findViewById(R.id.imageSwitcher1);


              for(int h=0;h<bitmapArray.size();h++)
              {
                  drawablesArray.add(new BitmapDrawable(bitmapArray.get(h)));
              }

これで、ドローアブル配列を Imageswitcher に渡し、必要なものを取得しました。

それが誰かを助けることを願って.....

于 2012-05-10T16:54:16.217 に答える