如何将图像从drawable文件夹添加到FrescoImageViewer?

时间:2017-12-30 10:07:55

标签: android arraylist fresco

public class MainActivity extends AppCompatActivity {

    ImageViewer Fresco;

    Integer[] images = {R.drawable.b1, R.drawable.b2, R.drawable.b3, R.drawable.b4, R.drawable.b5, R.drawable.b6, R.drawable.b7, R.drawable.b8, R.drawable.b9, R.drawable.b10};


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);



        new ImageViewer.Builder(MainActivity.this, images)
                .setStartPosition(R.drawable.b1)
                .show();


    }
}

我从git :: https://github.com/stfalcon-studio/FrescoImageViewer

尝试样本

2 个答案:

答案 0 :(得分:0)

通过他们的道路获得你想要的所有绘画!作为字符串,因为ImageViewer只需要String的列表或数组(即图像的URL!)

通过这样做获取每个图像的网址!这些

    String imageUri = "drawable://" + R.drawable.image;
or
    Uri path = Uri.parse("android.resource://com.rizwan.appo.gappo/" + R.drawable.naruto_img);
    String url1= path.toString();
or
    Uri otherPath = Uri.parse("android.resource://com.rizwan.appo.gappo/drawable/naruto_img");
    String url2= otherPath .toString();


ImageViewer Fresco;

    String[] images = {url1,url2,.......};


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);



        new ImageViewer.Builder(MainActivity.this, images)
                .setStartPosition(R.drawable.b1)
                .show();


    }
}

答案 1 :(得分:0)

mSimpleDraweeView.setImageURI(UriUtil.getUriForResourceId(R.drawable.ic_launcher));