图像未加载到从图库中选择的recyclerView中

时间:2017-10-21 16:16:37

标签: android android-recyclerview uri

基本上我使用github的图像选择器库从gallery中选择多个图像。选择图像没有问题,甚至没有获得uri但uris没有加载到回收站视图中。它没有显示任何错误或任何其他消息。

我的Uri获取代码:

 public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == Constants.REQUEST_CODE && resultCode == RESULT_OK && data != null) {
        //The array list has the image paths of the selected images
        ArrayList<Image> images = data.getParcelableArrayListExtra(Constants.INTENT_EXTRA_IMAGES);
        ArrayList<Uri> selected=new ArrayList<>();
        for (int i = 0, l = images.size(); i < l; i++) {
            selected.add(Uri.parse(images.get(i).path));
        }
                    Toast.makeText(getActivity().getApplicationContext(),selected.toString(),Toast.LENGTH_SHORT).show();
                    adapter = new CustomRecyclerViewAdapter(getActivity().getApplicationContext(),selected);
        recyclerView.setAdapter(adapter);

}}

适配器类代码:

 public void onBindViewHolder(final RecyclerViewHolder holder, final int position) {
  //ivbackground is imageView

          Glide.with(holder.ivBackground.getContext())
                .load(image.get(position)).into(holder.ivBackground);}

1 个答案:

答案 0 :(得分:0)

类似于来自网址的加载如何具有&#34; http://www。&#34;架构,Uri也应提供适当的架构,&#34; file://&#34;。也许你的不是。 尝试将其作为文件传递。 Glide.with(holder.ivBackground.getContext()) .load(new File(image.get(position))).into(holder.ivBackground);

相关问题