安卓:全屏图像滑块与刷卡,捏缩放手势 [英] Android: Fullscreen Image Slider with Swipe and Pinch Zoom Gestures

查看:143
本文介绍了安卓:全屏图像滑块与刷卡,捏缩放手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想按照这个例子:

<一个href=\"http://www.androidhive.info/2013/09/android-fullscreen-image-slider-with-swipe-and-pinch-zoom-gestures/\"相对=nofollow>链接到例如

他让全屏图像滑块与滑动并捏缩放手势。问题是,该实例包括SD卡的图片和要收集的资产文件夹的图片。有人能告诉我,我应该放在utils类的例子改为得到它?

非常感谢

 公开的ArrayList&LT;串GT; getFilePaths(){    Log.e(,帕索);
    ArrayList的&LT;串GT;文件路径=新的ArrayList&LT;串GT;();    文件目录=新的文件(
            android.os.Environment.getExternalStorageDirectory()
                    +文件分割符+ AppConstant.PHOTO_ALBUM);    如果(directory.isDirectory()){        文件[] listFiles = directory.listFiles();        如果(listFiles.length大于0){            的for(int i = 0; I&LT; listFiles.length;我++){                字符串文件路径= listFiles [I] .getAbsolutePath();                如果(IsSupportedFile(文件路径)){                    filePaths.add(文件路径);
                }
            }
        }
    }    返回文件路径;
}


解决方案

您可以从资产images文件夹这样的。

 尝试
{
 AssetManager上午= getAssets();
 字符串列表[] = am.list();
 INT文件= yourimagelist.length;
 的for(int i = 0; I&LT; =文件;我++)
 {
  BUF的BufferedInputStream =新的BufferedInputStream(am.open(名单[positionHere]));
  位图位图= BitmapFactory.de codeStream(BUF);
  imageView.setImageBitmap(位图);
  buf.close();
 }
 }
赶上(IOException异常E)
{
e.printStackTrace();
}

I'm trying to follow this example:

Link to example

He makes Fullscreen Image Slider with Swipe and Pinch Zoom Gestures. The problem is that the example includes pictures of the SDCard and want to collect pictures of the Assets folder. Could someone tell me I should change in the Utils class example to get it?

many thanks

public ArrayList<String> getFilePaths() {

    Log.e("", "paso");
    ArrayList<String> filePaths = new ArrayList<String>();

    File directory = new File(
            android.os.Environment.getExternalStorageDirectory()
                    + File.separator + AppConstant.PHOTO_ALBUM);

    if (directory.isDirectory()) {

        File[] listFiles = directory.listFiles();

        if (listFiles.length > 0) {

            for (int i = 0; i < listFiles.length; i++) {

                String filePath = listFiles[i].getAbsolutePath();

                if (IsSupportedFile(filePath)) {

                    filePaths.add(filePath);
                }
            }
        }
    }



    return filePaths;
}

解决方案

You can get images from assets folder this way.

try 
{
 AssetManager am = getAssets();
 String list[] = am.list("");
 int files = yourimagelist.length;
 for(int i= 0;i<=files ; i++)
 {
  BufferedInputStream buf = new BufferedInputStream(am.open(list[positionHere]));
  Bitmap bitmap = BitmapFactory.decodeStream(buf);
  imageView.setImageBitmap(bitmap);
  buf.close();
 }
 }   
catch (IOException e) 
{
e.printStackTrace();
}

这篇关于安卓:全屏图像滑块与刷卡,捏缩放手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆