To add an image, you need to create a custom cell, use the Recyclerview + ViewHolder concept:
In your activity, create the 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 (R.layout.recycler_main_item) item of your choice.