0

I want set progress bar until the next activity start.That mean i want to remove black screen while loading next page or activity.How to solve this problem?

yes I'm using button onClick and using listView to move next activity.

MMM
  • 63
  • 3
  • 10

3 Answers3

1
Button b1 = new Button(this);
b1.setOnTouchListener(new OnTouchListener() 
            {
                public boolean onTouch(View v, MotionEvent event) 
                {
                    int action = event.getAction();
                     if(action==0)
                     {
                     }
                     else  if(action == 1)
                     {   
                        final ProgressDialog dialog = ProgressDialog.show(myFirstActivity.this,"Please wait","Loading...",true);
                         new Thread() 
                         {
                               public void run() 
                               {
                                    try 
                                    {
                                        Thread.sleep(2000);
                                    } catch (InterruptedException e) 
                                    {
                                        e.toString();
                                        e.printStackTrace();
                                    }
                                    finally
                                    {
                                        dialog.dismiss();           
                                    }
                               }
                         }.start();
                      } 
                    return false;
                }
            });



     b1.setOnClickListener(new OnClickListener()
                {
                    public void onClick(View v) 
                    {
                             Intent i1 = new Intent(myFirstActiviyt.this,Second.class);
                             startActivity(i1);
                             }
                             });

Try this

Sumant
  • 2,775
  • 2
  • 22
  • 30
  • ah Sumant i need one more help how to use horizontal progress bar instead of this – MMM Jun 06 '11 at 09:20
  • just go to http://www.androidpeople.com/android-progress-dialog-style http://eagle.phys.utk.edu/guidry/android/progressBarExample.html http://developer.android.com/reference/android/widget/ProgressBar.html you will get info @ horizontal progress bar – Sumant Jun 06 '11 at 09:26
  • Hello Sumant i have one problem. In spinner progress dialog that spinner not rotating – MMM Jun 06 '11 at 10:39
0

http://developer.android.com/reference/android/widget/ProgressBar.html

GSerg
  • 76,472
  • 17
  • 159
  • 346
Nikunj Patel
  • 21,853
  • 23
  • 89
  • 133
0

try answer on this link

show progressbar on button click when going from 1 intent to other and data is coming from server

Community
  • 1
  • 1
Jaydeep Khamar
  • 5,975
  • 3
  • 32
  • 30