0

私はすでにアンドロイドからクラウドへのデータの挿入を完了しており、私がやろうとしていることは、保存されているクラウドからデータを取得したい (私の理解では) オブジェクト「クラウドに文字列データ型を含む」をリストし、それを TextView に設定すると、ここに私のコードがあります:

package com.cloud.test;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.parse.FindCallback;
import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //id from the cloud and perfectly working
        Parse.initialize(this, "idp7tOItFQ1TeQ87NqG5okzgsTzBZSfOmTh3LjbJ", "sPlps2HcBLzfBcZTG8uUFPi5gHkGbwFYVGHhGtwd");


    }
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.btn1:
            /**
             * this is for inserting data to cloud
             */
            EditText et1 = (EditText)findViewById(R.id.et1);
            EditText et2 = (EditText)findViewById(R.id.et2);
            EditText et3 = (EditText)findViewById(R.id.et3);
            String name = et1.getText().toString();
            int price = Integer.parseInt(et2.getText().toString());
            String desc = et3.getText().toString();
            ParseObject test = new ParseObject("Wardrobe");

            test.put("price", price);
            test.put("name", name);
            test.put("description", desc);
            test.saveInBackground();
            break;

        case R.id.btn2:
            /**
             * below is my problem, i don't know how do i actually get the data from the list
             * which is all String
             */
            ParseQuery query = new ParseQuery("Wardrobe");
            query.whereEqualTo("description", "male");
            query.findInBackground(new FindCallback() {
                @Override
                public void done(List<ParseObject> dataList, ParseException e) {
                    // TODO Auto-generated method stub
                     if (e == null) {
                         TextView tv1 = (TextView)findViewById(R.id.tv1);
                         TextView tv2 = (TextView)findViewById(R.id.tv2);
                         TextView tv3 = (TextView)findViewById(R.id.tv3);
                            /**
                             * here i want to set the data to the TextView to be viewed by the user
                             */
                            Log.d("score", "Retrieved " + dataList.size() + " scores");
                        } else {
                            Log.d("score", "Error: " + e.getMessage());
                        }
                }
            });
            break;
        default:
            break;
        }

    }
}

助けてくれてありがとう

これが私が使用するアップデートであり、String.value(dataList);私が得るものはこれですcom.parse.ParseObject@44f904b8, com.parse.ParseObject@44f90a30

4

2 に答える 2

0

オーバーライドされた toString メソッドを使用して別のものを出力しない限り、クラスと、メモリ アドレスなどと思われるものが出力されます。String.value (または toString - 同じもの) を使用する場合は、ParseObject の toString メソッドをオーバーライドする必要があります。そのコードにアクセスしたくない場合、またはそのコードにアクセスできない場合は、ParseObject クラスによって提供される getter メソッドから必要な文字列を手動で作成する必要があります。

于 2013-02-16T00:28:45.447 に答える
0
public void done(List<ParseObject> dataList, ParseException e) {
                    // TODO Auto-generated method stub
                     if (e == null) {

                           TextView tv1 = (TextView)findViewById(R.id.tv1);
                        for(int x = 0; x < scoreList.size(); x++)
                        {
                         String d =  scoreList.get(x).getString("name");                         
                         tv1.setText(tv1.getText()+" "+d);
                        }
                            Log.d("score", "Retrieved " + dataList.size() + " scores");
                        } else {
                            Log.d("score", "Error: " + e.getMessage());
                        }
                }
            });
于 2013-02-16T02:37:26.493 に答える