我已经完成了将数据从 android 插入到云中,我想要做的是,我想从云中获取存储的数据(在我的理解中)列出对象“在云中包含字符串数据类型”和将其设置为 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