Results 1 to 2 of 2
Thread: Android ProgressBar with threads
- 02-10-2012, 10:15 PM #1
Member
- Join Date
- Jan 2010
- Posts
- 19
- Rep Power
- 0
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>
- 02-10-2012, 11:59 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,716
- Rep Power
- 17
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-11-2012 at 12:05 AM.
Similar Threads
-
ProgressBar renderer Help?
By greatmajestics in forum AWT / SwingReplies: 0Last Post: 04-17-2010, 10:39 PM -
How to create a ProgressBar
By isuru in forum Advanced JavaReplies: 0Last Post: 01-09-2010, 07:44 PM -
Progressbar
By bubbless in forum Threads and SynchronizationReplies: 4Last Post: 07-16-2009, 04:32 PM -
problems with progressbar
By komunista88 in forum Threads and SynchronizationReplies: 1Last Post: 01-05-2009, 10:02 PM -
ProgressBar Demonstration
By Java Tip in forum SWT TipsReplies: 0Last Post: 07-11-2008, 05:52 PM
Bookmarks