[英]ListView using parse.com
Hey i am trying to fetch all the data from parse.com table. 嘿,我试图从parse.com表中获取所有数据。 My Table called "Code_Description" and i have two column that i have made into my table data they called "surveyCode" , "Description". 我的表称为“ Code_Description”,我有两列已写入表数据中,它们称为“ surveyCode”,“ Description”。 and i want to fetch them into listView the surveyCode and the Description . 我想将它们提取到listView surveyCode和Description中。 please help. 请帮忙。
i have this code but doesn't working . 我有此代码,但无法正常工作。
public class editSurveyManager extends ActionBarActivity {
//List<ParseObject> ob;
ListView listView;
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_survey_manager);
//Setting Data
adapter = new ArrayAdapter<String>(editSurveyManager.this,R.layout.activity_edit_survey_manager);
listView = (ListView)findViewById(R.id.listView);
ParseQuery<ParseObject> query = ParseQuery.getQuery("Code_Description");
query.setLimit(1000);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> markers, ParseException e) {
if (e == null) {
// update your list here somehow
// listAdapter.clear();
// listAdapter.addAll(markers);
for (ParseObject list : markers){
adapter.add((String)list.get("surveyCodes"));
}
listView.setAdapter(adapter);
} else {
Log.e("Error",e.getMessage());
}
}
});
Your first line is wrong. 您的第一行是错误的。 You should do something like that: 您应该这样做:
ParseQuery<ParseObject> query = ParseQuery.getQuery("Code_Description");
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> markers, ParseException e) {
if (e == null) {
// update your list here somehow
// listAdapter.clear();
// listAdapter.addAll(markers);
} else {
Log.e("Error",e.getMessage());
}
}
});
Parse will give you top 100 rows of your table. 解析将为您提供表的前100行。 But you can change it with that method below: 但是您可以使用以下方法更改它:
query.setLimit(1000); // max number you can set is 1000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.