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