Reputation: 462
I am getting data from a server in json format and passing it through a LazyAdapter in a ListView. I want when the tododone data from the server is true to enable the checkbox in the list. I have the code above for enabling the checkbox but does not work.
TextView todoid = (TextView)vi.findViewById(R.id.todoid); // id
TextView todotile = (TextView)vi.findViewById(R.id.todotitle); // title
CheckBox check = (CheckBox)vi.findViewById(R.id.check); // checkbox
String test;
HashMap<String, String> todo = new HashMap<String, String>();
todo = data.get(position);
// Setting all values in listview
todoid.setText(todo.get(TodoFragment.TAG_TODOID));
todotile.setText(todo.get(TodoFragment.TAG_TODOTITLE));
test=(todo.get(TodoFragment.TAG_TODODONE));
if (test.toString()=="true") {
check.setChecked(true);
}
return vi;
Thanks for the help.
Upvotes: 0
Views: 296
Reputation: 12122
Try use:
"true".equals(test.toString())"
instead of test.toString()=="true"
UPD:
The same sense, but more clear:
if (Boolean.parseBoolean(test))
PS: I don't know, why you use: test.toString()
if test
is already a String.
Hope it helps
Upvotes: 1