0

我试图展示ProgressDialog我获得服务器数据的时间。我有一个列表查看用户正在加载的内容,我正在使用 aAsyncTask来获取我的数据,并在preExecute(). 我想问题在于我的列表在 DialogFragment 中。如果我在 中创建ProgressDialogonCreateView()我也看不到它,但它位于另一个对话框的下方。我不知道是否可以优先考虑对话框,因为当我对活动执行相同操作时,我没有任何问题。

public class ListUsersDialog extends AbstractDialog {

    private ListView lv;     
    private CustomUsersAdapter adapter;    
    private List<UserResponse> usersList;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.dialog_list_users, container);

        //Se consulta por la lista de los usuarios, los parametros que se pasan es por si se quiere customizar el resultado en el futuro.
        AsyncGUI asyncDialogs = new AsyncGUI(this);
        asyncDialogs.execute(new RequestMessage(ConstantsRooms.GET_USERS, ((AbstractActivity)getActivity()).getUserName(), room));      
        getDialog().setTitle("Invitar a usuarios");

         // Listview Data     
        lv = (ListView) view.findViewById(R.id.list_view_users);
        inputSearch = (EditText) view.findViewById(R.id.inputSearch);
        checkFilterFriend = (CheckBox) view.findViewById(R.id.checkFilterFriend);

        usersList = new ArrayList<UserResponse>();
        adapter = new CustomUsersAdapter(usersList, (AbstractActivity)getActivity());
        lv.setAdapter(adapter);        

        ...
}

这是我与服务器连接并创建的 AsycTaskProgressDialog

public class AsyncGUI extends
        AsyncTask<RequestMessage, Object, Void> {


    private Updatable gui;
    private ProgressDialog pDlg;

    public AsyncGUI(Updatable gui) {        
        this.gui = gui;
    }

    .....

    @Override
    protected void onProgressUpdate(Object... values) {     
        gui.updateGUI(values[0]);       
    }

    @Override
    protected void onPostExecute(Void result) {     
        super.onPostExecute(result);
        if (pDlg != null){
            pDlg.dismiss();
        }
    }

    @Override
    protected void onPreExecute() {
        showProgressDialog();
    }

    /*
     * Muestra una pantalla de espera mientras se hace el procesamiento de datos..
     */
    private void showProgressDialog() {

        if (gui != null){
            pDlg = new ProgressDialog(gui.getContext());
            pDlg.setMessage("Espere por favor..");
            pDlg.setProgressDrawable(gui.getContext().getWallpaper());
            pDlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            pDlg.setCancelable(false);
            pDlg.show();
        }   
    }

}
4

0 回答 0