How to show imageViews in RecyclerView (Android)

android recyclerview imageview
how to show captured images dynamically in recyclerview layout
android-recyclerview image gallery
how to add static data in recyclerview in android
capturing images from camera and setting into recyclerview in android
set image from drawable in recyclerview
simple recyclerview android example
android recyclerview imageview size

I create a image's array : (logos.xml)

<integer-array name="icons"><Item>@drawable/pic_01 to @drawable/pic_04<item>

Then , in my class Function : I have

public Function(String name , int icon) { this.icon = icon }

public void getIcon() { return icon; }

Final , in FunctionAdapter , I get Imageview

punlic FunctionAdapter(Context context) { icons = context.getResources().getIntArray(R.array.icons);

my question is in onBindViewHolde(@NonNull FunViewHolder holder, int position)

 holder.itemImageView.setImageResource(icons[position])

is not working , I want to know what am I miss ? Thanks Help.

I want to change my ImageView (pic1 to pic4)

my Adapter :

public class FunctionAdapter extends RecyclerView.Adapter<FunctionAdapter.FunViewHolder>
{
   private final String[] functions;
   private final int[] icons;
   Context context;

   public FunctionAdapter(Context context){
       this.context = context;
       functions  = context.getResources().getStringArray(R.array.functions);
       icons = context.getResources().getIntArray(R.array.icons);
   }

  public FunViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {

  View view = LayoutInflater.from(context).inflate(R.layout.group_layout, parent,false);
   return new FunViewHolder(view);
  }

  public void onBindViewHolder(@NonNull FunViewHolder holder, int position) {

         holder.nameText.setText(functions[position]);
         holder.itemImageView.setImageResource(icons[position]);
   }

  public int getItemCount() { return functions.length; }

  public class FunViewHolder extends RecyclerView.ViewHolder{

   TextView nameText;
   ImageView itemImageView;
   public FunViewHolder(@NonNull View itemView) {
     super(itemView);
      nameText = itemView.findViewById(R.id.group_title);
      itemImageView = itemView.findViewById(R.id.group_logo);
    }
}

Update :

my mistake , logos.xml maybe the problem , but I don't know Why?

I decide to edit my icons :

private final int[] icons = new int[]{R.drawable.pic_01, R.drawable.pic_02, R.drawable.pic_03, R.drawable.pic_04} ;

then , pics will change.


you have to use String[] instead of String on constructor.

use

public Function(String[] name , int icon) { this.icon = icon }

instead of

public Function(String name , int icon) { this.icon = icon }

How to use a RecyclerView to show images from storage , It manages and optimizes the view holder bindings according to the scrolling aims to show a relatively quick way to add a RecyclerView to modern Android fragment_item.xml to display our image item with an ImageView for the image and  Seeing as the RecyclerView sample app is outdated and doesn’t even compile, this tutorial aims to show a relatively quick way to add a RecyclerView to modern Android Studio projects, and use it to display a list of random images we’ll download to our device. Creating a new project. Make a new project (or open an existing one).


Use setImageDrawable() method to load local drawables instead of using setImageResource.

holder.itemImageView.setImageDrawable(context.getResources().getDrawable(icons[position]))

RecyclerView for Android Beginners, RecyclerView for Android Beginners - How to display data - Main image Connect constraints to ImageView and top constraint to “name” TextView. Android RecyclerView with multiple views (multiple view holder) implementation complete. You can create more complex RecyclerView using this like Flipkart dashboard and facebook feed page.


try this code 

 private int[] confirmIcon = {R.drawable.ic_action_green, 
                              R.drawable.ic_action_yellow, 
                              R.drawable.ic_action_red};



 switch ("your condition") {
            case 0:
                holder.ivConfirm.setImageResource(confirmIcon[0]);
                break;
            case 1:
                holder.ivConfirm.setImageResource(confirmIcon[1]);
                break;
            case 2:
                holder.ivConfirm.setImageResource(confirmIcon[2]);
                break;


        }

Android tutorial (2018) - 30, In this video we are going to create a little bit complex recycler view, with images and Text on it Duration: 19:46 Posted: Mar 16, 2018 hello Android developer,today i post new Tutorial about upload image to firebase and display image in recyclerview android.In This Time manny application used firebase.so we learn another Tutorial about firebase.


Android Recyclerview With ImageView, android #recyclerview #imageview Android Recyclerview With ImageView Part 1 Link (How Duration: 11:34 Posted: Oct 9, 2019 I want to implement RecyclerView in bottom navigation fragment that contains CardViews with a TextView and an ImageView. I also have an onClickListener on every card that open new activity. but my recyclerview don't show anything and gives null point exception Logcat.I don't know what I am missing here. Model Class


Create different view types in RecyclerView Android, ViewHolder class. public static class BannerTypeViewHolder extends RecyclerView.ViewHolder { ImageView bannerImg; public  I am trying to use a RecyclerView as a horizontal ListView.I am trying to figure out how to highlight the selected item. When I click on one of the items, it gets selected and it is highlighted properly but when I click on another one, the second one gets highlighted with the older one.


Glide'ing your way into RecyclerView state invalidation, A mobile software engineer with a passion for Android and clean, maintainable code. So, for instance, if an app displaying a RecyclerView undergoes a config fun ImageView.load(imageAddress: String) { Glide.with(this)  Intermediate. RecyclerView for Android Beginners - How to display data. RecyclerView is a component that displays data in different ways and is made with contemporary techniques to make scrolling as smooth as possible and to make development easier.