我正在使用Parse.com,我正试图在数据加载到gridview时显示进度。看看下面我的尝试。进度条永远不会出现。它只显示一个白色屏幕,然后开始显示gridview项目。
rListActivity.java
public class rListActivity extends Activity {
pAdapter padapter;
GridView gridview;
ProgressDialog mProgressDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview_main);
gridview = (GridView) findViewById(R.id.gridview);
padapter = new pAdapter(this);
padapter.loadObjects();
padapter.addOnQueryLoadListener(new ParseQueryAdapter.OnQueryLoadListener<Meal>() {
@Override
public void onLoading() {
mProgressDialog = new ProgressDialog(rListActivity.this);
mProgressDialog.setMessage("Loading...");
mProgressDialog.setIndeterminate(false);
mProgressDialog.show();
}
@Override
public void onLoaded(List<Meal> objects, Exception e) {
gridview.setAdapter(padapter);
mProgressDialog.dismiss();
}
});
}
pAdapter.java
public class pAdapter extends ParseQueryAdapter<Meal> {
public pAdapter(Context context) {
super(context, new ParseQueryAdapter.QueryFactory<Meal>() {
public ParseQuery<Meal> create() {
ParseQuery query = new ParseQuery("Meal");
query.orderByAscending("title");
return query;
}
});
}
......
Itemviews....
答案 0 :(得分:0)
我可能会迟到但答案很简单。
您需要在
之后致电padapter.loadObjects();
padapter.addOnQueryLoadListener(new ParseQueryAdapter.OnQueryLoadListener<Meal>() {
@Override
public void onLoading() {
mProgressDialog = new ProgressDialog(rListActivity.this);
mProgressDialog.setMessage("Loading...");
mProgressDialog.setIndeterminate(false);
mProgressDialog.show();
}
@Override
public void onLoaded(List<Meal> objects, Exception e) {
gridview.setAdapter(padapter);
mProgressDialog.dismiss();
}
});