hi,
I am working on ProgressDialog box in my application, its running but
the problem is that status is not updating.
This is my code please any one help me.
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ProgressDailogDemoActivity extends Activity
{
ProgressDialog pd;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button)findViewById(R.id.bt1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showDialog(1);
}
});
}
public Dialog onCreateDialog(int id){
pd = new ProgressDialog(this);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pd.setMessage("waiting.........");
myThread m = new myThread(myHandler);
m.start();
return pd;
}
final Handler myHandler = new Handler()
{
public void handleMessage(Message msg)
{
int total = msg.getData().getInt("total");
pd.setProgress(total);
}
};
public class myThread extends Thread
{
Handler h;
int count;
myThread(Handler h)
{
this.h=h;
}
public void run()
{
count=0;
while(count!=100)
{
try {
Thread.sleep(1000);
}
catch(InterruptedException e) {
}
count++;
Message msg = h.obtainMessage();
Bundle b = new Bundle();
b.putInt("total",count);
msg.setData(b);
}
}
}
}
Thanking you,
Nagu.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en