从解析到recyclerview检索数据

时间:2015-04-24 07:51:08

标签: android parse-platform

我的代码应该从解析数据库中检索标题并将其设置为TextView。当检索到textview的标题后,它会显示一个没有String的空白TextView。

这是我的代码

final TextView textView1 = (TextView) findViewById(R.id.textView);
final TextView textView2 = (TextView) findViewById(R.id.textView2);
final TextView textView3 = (TextView) findViewById(R.id.textView3);
final TextView textView4 = (TextView) findViewById(R.id.textView4);

ParseQuery<ParseObject> query = ParseQuery.getQuery("Ads");
query.getInBackground("xWMyZ4YEGZ", new GetCallback<ParseObject>() {
    @Override
    public void done(ParseObject parseObject, com.parse.ParseException e) {
        if (e == null) {
            t = parseObject.getString("title");;
            ParseFile image = parseObject.getParseFile("adPhoto");
        } else {
        }
    }
});
textView1.setText(t);

}

为什么我不能将字符串t设置为textview,任何人都可以帮助我吗?请。

2 个答案:

答案 0 :(得分:0)

你有一点错误,你应该在执行查询后设置texview

final TextView textView1 = (TextView) findViewById(R.id.textView);
        final TextView textView2 = (TextView) findViewById(R.id.textView2);
        final TextView textView3 = (TextView) findViewById(R.id.textView3);
        final TextView textView4 = (TextView) findViewById(R.id.textView4);

        ParseQuery<ParseObject> query = ParseQuery.getQuery("Ads");
        query.getInBackground("xWMyZ4YEGZ", new GetCallback<ParseObject>() {
            @Override
            public void done(ParseObject parseObject, com.parse.ParseException e) {
                if (e == null) {
                    t = parseObject.getString("title");;
                    ParseFile image = parseObject.getParseFile("adPhoto");
                    // this should be call on ui thread
                    textView1.setText(t);
                } else {
                }
            }
        });

答案 1 :(得分:0)

你必须写

  

textView1.setText(t)的

完成方法