android - Would Start a new activity after the progessbar reached 100% -
i facing problem can't start new activity after progress bar reached 100% .this code error @ startactivity. main.java package com.example.hprogressbarexmaple;
import android.app.activity; import android.os.bundle; import android.os.handler; import android.os.message; import android.util.log; import android.widget.progressbar; public class hprogressbarexmaple extends activity { protected static final int max_progress = 100; protected static final long sleep_time = 200; /** called when activity first created. */ progressbar myprogressbar; int myprogress = 0; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); myprogressbar = (progressbar) findviewbyid(r.id.myprogress); new thread(mythread).start(); } private runnable mythread = new runnable() { @override public void run() { // don't hard code things, use constant max progress value while (myprogress < max_progress) { try { myhandle.sendmessage(myhandle.obtainmessage()); // same thread.sleep(sleep_time); } catch (exception ex) { // never live empty catch statement, missing // exceptions , // can't correct them log.e("mycurrentclass", "error during async data processing", ex); }// catch }// while // start new activity here startactivity(hprogressbarexmaple.this, list.class); }// met handler myhandle = new handler() { @override public void handlemessage(message msg) { // todo auto-generated method stub myprogress++; myprogressbar.setprogress(myprogress); } }; }; }
i searched alot can't solution. please me , correct me if going wrong .
try way:
intent intent = new intent(hprogressbarexmaple.this,list.class); hprogressbarexmaple.this.startactivity(intent);
and not forget add list activity
in manifest.xml
Comments
Post a Comment