Results 1 to 2 of 2
  1. #1
    isuru is offline Member
    Join Date
    Jan 2010
    Posts
    19
    Rep Power
    0

    Default Android ProgressBar with threads

    I am working on ProgressBar class in android, but I can't make it progress through 5 seconds and load the application. Everything works but the progress bar not progressing. Here is the code.

    Java Code:
    public class StartPoint extends Activity{
    
    ProgressBar progressBar;
    private int progressBarStatus = 0;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
    
        progressBar = (ProgressBar)findViewById(R.id.progressBar1);
    
    
        Thread timer = new Thread(){
            public void run(){
                try{
                    sleep(5000);
                    while(progressBarStatus < 5000){
                        progressBar.setProgress(progressBarStatus);
                        progressBarStatus += 1000;
    
                    }
                }catch(InterruptedException e){
                    e.printStackTrace();
                }finally{
                    Intent openMainList = new Intent(StartPoint.this, in.isuru.caf.MainList.class);
                    startActivity(openMainList);
                }
            }
        };
        timer.start();
    }
    
    protected void onPause(){
        super.onPause();
        finish();
    }
    }
    Java Code:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/mary_mother_of_god" />
    
    <ProgressBar
        android:id="@+id/progressBar1"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1.67" />
    
    </LinearLayout>

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Android ProgressBar with threads

    javaprogrammingforums.com.

    And answered at stackoverflow with follow on request for "the whole code" which was provided. DIfferent approach suggested at Android Developers (GG).

    @OP: Please don't waste people's time like this. Let everyone know if the discussion is taking place on multiple forums so that anyone contributing knows what is being said. And when you get an answer post a link to it from from whatever threads you have started.
    Last edited by pbrockway2; 02-10-2012 at 11:05 PM.

Similar Threads

  1. ProgressBar renderer Help?
    By greatmajestics in forum AWT / Swing
    Replies: 0
    Last Post: 04-17-2010, 09:39 PM
  2. How to create a ProgressBar
    By isuru in forum Advanced Java
    Replies: 0
    Last Post: 01-09-2010, 06:44 PM
  3. Progressbar
    By bubbless in forum Threads and Synchronization
    Replies: 4
    Last Post: 07-16-2009, 03:32 PM
  4. problems with progressbar
    By komunista88 in forum Threads and Synchronization
    Replies: 1
    Last Post: 01-05-2009, 09:02 PM
  5. ProgressBar Demonstration
    By Java Tip in forum SWT
    Replies: 0
    Last Post: 07-11-2008, 04:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •