Android ProgressDialog inside another dialog

Posted by La bla bla on Stack Overflow See other posts from Stack Overflow or by La bla bla
Published on 2012-11-03T22:57:48Z Indexed on 2012/11/03 23:00 UTC
Read the original article Hit count: 175

Filed under:
|
|
|

I'm working on a game using AndEngine, and I need to show the users the list of his Facebook friends. I've created my custom Adatper and after the loading finishes everything works great. I have a problem with the loading it self.

The ListView is inside a custom dialog, since I don't really know how to create one using AndEngine, So inside this dialog, I'm running an AsyncTask to fetch the friends' info, in that AsyncTask I'm have a ProgressDialog. The problem is, the ProgressDialog shows up behind the dialog that contains the to-be list (which while loading, is just the title). I can see the ProgressDialog "peeking" behind that dialog.. Any Ideas?

Here's some code:

FriendsDialog.java

private ProgressDialog dialog;

//Constructor of the AsyncTask
public FriendsLoader(Context context) {
    dialog = new ProgressDialog(context);
    dialog.setMessage("Please wait..\nLoading Friends List.");
}

@Override
protected void onPreExecute() {
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    dialog.setView(inflater.inflate(R.layout.loading, null));
    dialog.setMessage("Please wait..\nLoading friends.");
    dialog.show();
}

@Override
protected void onPostExecute(ArrayList<HashMap<String, Object>> data) {
    if (dialog.isShowing()) {
        dialog.dismiss();
    }
    MyAdapter myAdapter = new MyAdapter(context, data);
    listView = (ListView) findViewById(R.id.list);
    listView.setAdapter(myAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> myAdapter, View myView, int myItemInt, long mylng) {
            String id = (String) listView.getItemAtPosition(myItemInt);
            listener.onUserSelected(id);
            dismiss();
        }
    });
}

© Stack Overflow or respective owner

Related posts about java

Related posts about android