0

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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.