简体   繁体   English

按钮上的加载对话框,进度对话框单击

[英]Loading Dialog, Progress Dialog on Button Click

Hi i want to show a loading or progress dialog first for 1 second before button do anything else.... please help 嗨我想首先显示加载或进度对话1秒钟,然后按钮做其他事情....请帮忙

    button1 = (Button) findViewById(R.id.button1);
    button1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

       <!-- want to a Show a Loading or Progress Dailog for 1 Second  -->

            if (isInternetPresent) {
                // Internet Connection is Present
            } else {
                // Internet connection is not present
                InternetNotContectedAlert();
            }

Just do it like this,it will work. 就这样做,它会起作用。

    ProgressDialog csprogress=new ProgressDialog(NextActivity.this);
        Button csButton=(Button)findViewById(R.id.txtx);
        csButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                csprogress.setMessage("Loading...");
                csprogress.show();
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        csprogress.dismiss();
//whatever you want just you have to launch overhere.


                    }
                }, 1000);//just mention the time when you want to launch your action 

            }
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 进度对话框未显示在列表视图的按钮单击事件中 - Progress dialog not showing in button click event in listview 如何在Android中单击警报对话框的按钮时启动进度对话框? - How to start progress dialog on button click of alert dialog in android? 异步任务不显示按钮单击事件的进度对话框 - Asynchronous task not show Progress Dialog on click event of button Android加载带有进度对话框的列表视图 - Android loading listview with progress dialog Android-仅在AsyncTask未完成的情况下,单击按钮上的“显示进度对话框” - Android - Display Progress Dialog on button click ONLY if AsyncTask has not completed 当单击按钮时,在连接WiFi时,在Android上显示进度对话框 - when click button, while connected wifi, show progress dialog on android 当我单击该按钮时我有一个按钮,我只想显示进度对话框2秒钟,如何在2秒钟后关闭进度对话框 - I have button when I click on that button I want to show progress dialog only for 2 seconds, how to dismiss progress dialog after 2 seconds 使用“进度对话框”按钮取消AsyncTask - Cancel AsyncTask with Progress Dialog button Android后退按钮和进度对话框 - Android Back Button and Progress Dialog 在进度对话框中添加取消按钮 - Add cancel button on progress dialog
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM