I'm having a little problem that I can't solve and I searched the net and I can't find an answer to it. I am making a small android application for my phone and I have a listview item with few items in it. On click on some of the item from my listView, I want to show a little check mark on the left side so a user can see what he selected. Next time the user opens or enters that Activity, there should already be check marker on what he clicked last time.
I set the drawableLeft icon like this but now every listView item I have has the same check marker.
public class BazaAdapter extends ArrayAdapter<bazeKlasa>
{
private Context mContext;
int mResource;
public BazaAdapter(@NonNull Context mContext, int resource, @NonNull
ArrayList<bazeKlasa> objects) {
super(mContext, resource, objects);
this.mContext = mContext;
this.mResource = resource;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull
ViewGroup parent) {
String imeBaze = getItem(position).getBaza();
String nazivBaze = getItem(position).getImeBaze();
bazeKlasa Baza = new bazeKlasa(imeBaze, nazivBaze);
LayoutInflater inflater = LayoutInflater.from(mContext);
convertView = inflater.inflate(mResource,parent,false);
TextView TextGornji = (TextView)
convertView.findViewById(R.id.lblcountryname);
TextGornji.setText(nazivBaze);
return convertView;
}
}