开发者

Android: show progress dialog inside class extended with Dialog

开发者 https://www.devze.com 2023-04-03 08:15 出处:网络
I have a a class that that is extended with Dialog itself. There are certain options available in dialog that sends request to server. I want to show a progress wait dialog when user click on any such

I have a a class that that is extended with Dialog itself. There are certain options available in dialog that sends request to server. I want to show a progress wait dialog when user click on any such option.

but Dialog in not showing may be because I am showing a progress dialog inside a dialog.

code is really very simple.

public class LeaderBoard extends Dialog implements View.OnClickListener {
public LeaderBoard(Context context) {
        super(context, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
        this.mContext = context;

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.leaderboard);

public void onClick(View paramView) {
..............
if (this.waitDialog != null) {
            this开发者_开发技巧.waitDialog.show();
        }
new Runnable() {

                    @Override
                    public void run() {

                        mHandler.post(new Runnable() {

                            @Override
                            public void run() {
                                send request to server
                                waitDialog.dismiss();
                            }
                        });

                    }
                }.run();


Hi Please try below code.

public class LeaderBoard extends Dialog implements View.OnClickListener {
Activity mActivity;
private final ProgressDialog dialog;
public LeaderBoard(Activity activity) {
        super(activity, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
        mActivity = activity;

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.leaderboard);
        dialog = new ProgressDialog(mActivity);

public void onClick(View paramView) {
..............
if (this.waitDialog != null) {
            this.dialog.setMessage("Please Wait...");
            this.dialog.show();
        }
new Runnable() {

                    @Override
                    public void run() {

                        mHandler.post(new Runnable() {

                            @Override
                            public void run() {
                                send request to server
                                this.dialog.dismiss();
                            }
                        });

                    }
                }.run();

Thanks, Nik...

0

精彩评论

暂无评论...
验证码 换一张
取 消