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

Android

How 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.

can you post your query code?

2 Answers

According 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());
                    }
                }

the 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));