To add an image, you need to create a custom cell, use the concept of Recyclerview + Viewholder:
In your Activity create Adapter by passing your list:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RecyclerView rvMain = view.findViewById(R.id.rvMain);
List<String> dados = Arrays.asList( "Produção Geral", "Perdas", "Contagem Por Máquina", "OEE", "Paradas de Máquina");
final MainRecyclerAdapter adapter = new MainRecyclerAdapter(dados, context, this);
rvMain.setAdapter(adapter);
rvMain.setHasFixedSize(true);
rvMain.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
}
Mainrecycleradapter
public class MainRecyclerAdapter extends RecyclerView.Adapter<MainViewHolder> {
List<String> dados;
private Context context;
public MainRecyclerAdapter(List<String> dados, Context context) {
this.dados = dados;
this.context = context;
}
@Override
public MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_main_item, parent, false);
return new MainViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull final MainViewHolder holder, int position) {
holder.setText(dados.get(position));
holder.setImage(R.mipmap.ic_launcher);
}
@Override
public int getItemCount() {
return dados.size();
}
@Override
public int getItemViewType(int position) {
return position;
}
}
Mainviewholder
public class MainViewHolder extends RecyclerView.ViewHolder {
TextView textView;
ImageView imageView;
public MainViewHolder(View itemView) {
super(itemView);
textView = itemView.findViewById(R.id.textView);
imageView = itemView.findViewById(R.id.imageView);
}
public void setText(String text) {
textView.setText(text);
}
public void setImage(int image) {
imageView.setImageResource(image);
}
}
Add a Recyclerview to your Mainactivity xml and create an xml related to the Recyclerview item (R.layout.recycler_main_item) of your preference.