I want to have a heart without color in the listView when I clicked on it, its color turns red and save when exit the app.
The StructAnatomy class:
public class StructAnatomy {
public String title;
//public ImageView heart_empty;
//public boolean done;
}
THe AdapterAnatomy class:
the heart_impty is an image that no color and heart_fill has color.
public class AdapterAnatomy extends ArrayAdapter<StructAnatomy> {
public AdapterAnatomy(ArrayList<StructAnatomy> array) {
super(G.context, R.layout.adapter_anatomy, array);
}
public static class ViewHolder {
public ViewGroup layoutRoot;
public TextView txtTitle;
//public ImageView heart_empty;
public ViewHolder(View view) {
layoutRoot = (ViewGroup) view.findViewById(R.id.layoutRoot);
txtTitle = (TextView) view.findViewById(R.id.txtTitle);
//heart_empty.setImageResource(R.drawable.heart_fill);
}
public void fill(ArrayAdapter<StructAnatomy> adapter, StructAnatomy item, final int position) {
txtTitle.setText(item.title);
//heart_empty.setEnabled(item.done);
layoutRoot.setOnClickListener(new OnClickListener() {
//******************************************************************************************
@Override
public void onClick(View arg0) {
Intent intent = new Intent(G.currentActivity, Anatomy1_2.class);
intent.putExtra("POSITION", position);
G.currentActivity.startActivity(intent);
}
});
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
StructAnatomy item = getItem(position);
if (convertView == null) {
convertView = G.inflater.inflate(R.layout.adapter_anatomy, parent, false);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.fill(this, item, position);
return convertView;
}
}