Question

Hi guys first of all point out that I'm newbie and I apologize for my mistakes. Here my code:

gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
        if ("UNFOCUSED".equals(v.getTag())) {   
            v.setBackgroundResource(R.drawable.item_backgroundColored);
            v.setTag("FOCUSED");
        }
        else {
            v.setBackgroundResource(R.drawable.item_background);
            v.setTag("UNFOCUSED");
        }
}
});

I want to make permanent (even when my application is no longer in RAM) my selection (selection means all the colored cells), so I thought to SharedPreferences but how do I remember all colored cells, and my View "v" in the method "onItemClick()" is dynamic according to my clicks.

Was it helpful?

Solution

Why not a SQLite Database ?! Save all the selected items in an array and persist your grid state in onPause().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top