Reputation: 323
I have a list of [testNames, testScores] that I want displayed in a listView.
I want the backgrounds of the listView items to be covered by their respective testScore % in green.
For example, If I have 3 tests with scores 40, 70 and 100, then I want the 3 listview items to have background 40% green, 70% green and 100% green.
I am using ParseQueryAdapter for setting listView's text as shown below.
//Retrieve number of tests for current user from Parse
ParseQueryAdapter.QueryFactory<ParseObject> factory =
new ParseQueryAdapter.QueryFactory<ParseObject>() {
public ParseQuery create() {
ParseQuery query = new ParseQuery("Tests");
query.whereEqualTo("username", currentUser.getUsername());
query.orderByAscending("testName");
return query;
}
};
final ParseQueryAdapter<ParseObject> adapter = new ParseQueryAdapter<ParseObject>(
Home.this, factory);
//Display session string for ListView Selection
adapter.setTextKey("testName");
chooseTestListView.setAdapter(adapter);
The above code helps display the testNames in my listview. But I would like to know how to set the backgrounds of each of the list item's proportionally to the testScore.
Thanks in advance.
Upvotes: 0
Views: 105
Reputation: 430
Well for this you will need to create a custom adapter that extends parse query adapter of an object There you can add a progress bar that is customized to look like a background and let the percentage equal to result
Upvotes: 0