Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
jaydev
837 PointsHow do i display a string from Parse.com in a TextView?
Ive been trying to display a string from my Parse.com table "Facts" into a factTextView with no luck. What method can i use to display a string queried from a table? Thanks.
2 Answers
jaydev
837 PointsAccording to Parse.com, "In the callback from the find query, you should use a loop and iterate through the list. It is a list of ParseObjects, so rather than turning it into a string, you can use the actual objects."
public void done(List<ParseObject> factList, ParseException e) {
if (e == null) {
for (ParseObject factsObject : factList) {
factLabel.setText("" + factsObject.get("Fact"));
}
Log.d("score", "Retrieved " + factList.size() + " scores");
} else {
Log.d("score", "Error: " + e.getMessage());
}
}
Stone Preston
42,016 Pointsthe parse query returns a list (although it probably only contains one object). try setting the label.text to the 0 index of the factList
factLabel.setText(factsList.get(0));
Stone Preston
42,016 PointsStone Preston
42,016 Pointscan you post your query code?