The overall idea is to change the background of a TextView in a ListView based on the value that is put into it.
E.g. if the value entered is true, then the colour changes.
however I having trouble getting the specific value rather than the string
Here is my controller
public ArrayList<HashMap<String, String>> getAllSkills () {
Log.d(LOGCAT, "getAll");
ArrayList<HashMap<String, String>> wordList;
wordList = new ArrayList<HashMap<String, String>>();
String selectQuery = "SELECT * FROM " + "characterSkills";
SQLiteDatabase database = this.getWritableDatabase();
Cursor cursor = database.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
HashMap<String, String> map = new HashMap<String, String>();
map.put("skillId", cursor.getString(0));
map.put("skillName", cursor.getString(1));
map.put("ability", cursor.getString(2));
map.put("rank", cursor.getString(3));
map.put("enabled", cursor.getString(4));
wordList.add(map);
} while (cursor.moveToNext());
}
return wordList;
}
Which is being called by this:
ArrayList<HashMap<String, String>> characterSkills = controller
.getAllSkills();
ListAdapter adapter = new SimpleAdapter(CharacterSheet.this,
characterSkills, R.layout.dd_skill_entry, new String[] {
"skillId", "skillName", "ability", "rank", "enabled" },
new int[] { R.id.skillid, R.id.skillname, R.id.ability,
R.id.rank, R.id.enabled });
Toast.makeText(getApplicationContext(), "" + characterSkills.get(4), Toast.LENGTH_LONG).show();
setListAdapter(adapter);
The toast returns the entire hashmap at that location rather than the "enabled" value that I want.
So my question is how do I get this value and how do I check its true and if it is change the background colour of the specific Views (R.id.enabled) it is entered into.
HashMapinside anArrayList? In any case, you first need to access the specificHashMapwithin theArrayList's, and then get the specific value from theHashMap