1

Hi i want to show a loading or progress dialog first for 1 second before button do anything else.... please help

    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();
            }
Sam
  • 121
  • 1
  • 2
  • 11
  • This has been answered many times: http://stackoverflow.com/a/6159735/2045570 – nedaRM Oct 09 '13 at 02:43
  • possible duplicate of [Android: Show spinning wheel dialog while loading data](http://stackoverflow.com/questions/6159702/android-show-spinning-wheel-dialog-while-loading-data) – frozenkoi Oct 09 '13 at 02:45

1 Answers1

3

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 

            }
        });
Bhaskar
  • 911
  • 6
  • 18
rkv
  • 131
  • 6