我在findInBackground()
方法中从解析中获取数据。我想在获取所有数据并显示ListView
时使进度条不可见,但在此代码中,进度条正确隐藏但进度条已停止。当所有数据都没有从数据库中获取时,我想继续进度条。
Listuser = (ListView) rootView.findViewById(R.id.listUser);
pbLoading = (ProgressBar) rootView.findViewById(R.id.pbLoading);
pbLoading.setVisibility(View.VISIBLE);
Listuser.setVisibility(View.INVISIBLE);
cuserlist.add(ParseUser.getCurrentUser().getUsername());
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.orderByDescending("point");
query.findInBackground(new FindCallback<ParseUser>() {
public void done(List<ParseUser> objects, ParseException e) {
if (e == null) {
for (final ParseObject object : objects) {
String user = object.getString("username").toString();
ParseFile pimage = object.getParseFile("image");
// Log.e("without user", String.valueOf(user));
list.add(user);
int pos = list.indexOf(user);
System.out.println("The index of User is: " + pos);
userlist.add(user);
Bitmap bmp = null;
URL img_value = null;
try {
img_value = new URL(pimage.getUrl());
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
bmp = BitmapFactory.decodeStream(img_value.openConnection()
.getInputStream());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
image.add(bmp);
currentRank.add(String.valueOf(pos + 1));
pbLoading.setVisibility(View.INVISIBLE);
Listuser.setVisibility(View.VISIBLE);
final CustomUser adapter = new CustomUser(
getActivity(), userlist, image, currentRank);
Listuser.setAdapter(adapter);
}
} else {
}
}
});