从parse.com接收文本文件并放在textview中

问题描述 投票:2回答:1

我正在尝试从Parse中的文本文件中获取文本,并将其转换为String并将文本放置在textview中。我尝试通过与图像(AppetizerRecipe.java)相同的方式进行研究时建议的操作

您可以从图像中看到,我有一列“食谱”,其中包含文本文件。 Logcat显示文件是从解析中检索的,当我单击它时,它显示了我的文件。我似乎无法将文字显示在textview上。

onListItemClick:

@Override
protected void onListItemClick(ListView l, View v, int position, long
        id) {
    super.onListItemClick(l, v, position, id);

    ParseObject po = mAppetizers.get(position);

    ParseFile recipes = po.getParseFile("recipe");


    // TODO: Get fields from Parse
    String title = po.getString(AppetizerRecipe.ARG_NAME);
    String time = po.getString(AppetizerRecipe.ARG_TIME);
    String ID = po.getObjectId().toString();
        Log.d("Appetizer", "object: " + ID);

    Intent intent = new Intent(Appetizer.this, AppetizerRecipe.class);

    // TODO: Put extras
    intent.putExtra(AppetizerRecipe.ARG_NAME, title);
    intent.putExtra(AppetizerRecipe.ARG_TIME, time);
    intent.putExtra("ID", ID);
        Log.d("Appetizer", "object: " + ID);


    startActivity(intent); // TODO:  In other activity, get these extras
}

AppetizerRecipe.java

ParseQuery<ParseObject> gettext = new ParseQuery<>("Appetizers"); 
    gettext.addAscendingOrder("appetizer"); 
    gettext.whereEqualTo("ID", ID); 
    gettext.getInBackground(ID, new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject textobject, ParseException e) {
            if (e == null) {
                // success
                final ParseFile textObject = (ParseFile) textobject.get("recipe");
                textObject.getDataInBackground(new GetDataCallback() {
                    public void done(byte[] data, ParseException e) {
                        if (e == null) {
                            // use data for something

                        } else {

                        }
                    }
                });

            } else {
                // fail
                Log.d("test", "Error Message..." + e.getMessage());
            }
        }
    });

parse.com:

parse.com

Logcat:

Logcat

来自parse.com的文本文件:

Text file from parse.com

我正在尝试从Parse中的文本文件中获取文本,并将其转换为String并将文本放置在textview中。我尝试以某种方式做某人在研究时建议的方式...

java android parse-platform textview
1个回答
1
投票

String中获取byte[]

© www.soinside.com 2019 - 2024. All rights reserved.