如何从Parse.com数据库对象,并显示在Android中的TextView? [英] How to retrieve objects from Parse.com database and show it in Android TextView?

查看:138
本文介绍了如何从Parse.com数据库对象,并显示在Android中的TextView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个简单的测验MCQ应用。

I am building a simple MCQ quiz app.

我所做的就是作出Parse.com数据库和存储的问题,可能的答案,并在它的正确的解决方案。

What I did was make a database on Parse.com and stored the questions, possible answers and the correct solution in it.

该Parse.com表可以在此图像中可以看出: http://i.imgur.com/ yXQ2FX1.png

The Parse.com table can be seen in this image: http://i.imgur.com/yXQ2FX1.png

正如你可以看到,每个对象都有一个问题,有4个可能的选择和正确的答案。

As you can see, each object has a question, with 4 possible options and the correct answer.

现在,我想说明一个TextView里面的问题和内四个不同的按钮的选项。用户会点击相应的按钮接听和应用程序将检查是否正确的按钮是pressed。

Now, I want to show the questions inside a TextView and the options inside four different buttons. The user will click on the correct button to answer and the app will check if the correct button was pressed.

我如何检索特定对象的属性内容到一个TextView或按钮?

注:我试过以下为查询的在线文档。他们的例子展示了如何通过查询检索对象,而不是如何显示TextViews或如何对这些对象的存储局部变量里面的那些对象。例如,我知道如何查询特定对象,但一旦我得到的对象,我怎么检索该对象的特定属性,我怎么什么是存储内部optionA字段,并将其存储在字符串中?

我知道有一个ListView适配器,但你可以看到我不能在这里使用一个ListView。
我尝试以下code试图查询对象转换为字符串,但没有奏效。我真的是一个新手,所以也许我做一些愚蠢的事。请帮助我。

推荐答案

尝试是这样的:

    query.whereEqualTo("ques",/*enter question number here*/);
       query.findInBackground(new FindCallBack<ParseObject>(){
                 public void done(List<ParseObject> l; ParseException e){
                          if(e == null){
                                 for(int i = 0; i <l.size();i++){
                                       textView.setText(l.get(i).getString("optionA"))
                                     }
                               }
                              else{//handle the error
                                        }
    }

});

这篇关于如何从Parse.com数据库对象,并显示在Android中的TextView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆