On Wed, Aug 26, 2009 at 7:43 PM, AntoniMG <tonio...@gmail.com> wrote:
> > Hi, > > We are having some problems showing a ProgressDialog on a onCreate > method (for example, when the app calculates some operations before > starts). > > This is a example of what is our problem: > > public class dialog extends Activity { > /** Called when the activity is first created. */ > int res; > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > TextView tv = (TextView) findViewByID(R.layout.textv); > > final ProgressDialog pd = ProgressDialog.show(this, "Title", > "Message", > true, false); Instead try using final ProgressDialog pd = new ProgressDialog(this); pd.set*(); pd.show(); > > > new Thread(new Runnable() { > public void run() { > try { > res = 2+2; > Thread.sleep(1000); > } catch (InterruptedException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } //msg to handler to dismiss the dialog > > pd.dismiss(); > } > }).start(); > > > tv.setText(res); U'll hv to make use of a handler for this purpose. > > } > } > > > > We cant do the tv.setText in the thread because it throws an > Exception. The problem is the dialog doenst appear until the Thread is > finished, > > Any help? > > > -- Regards, Sujay Ogden Nash <http://www.brainyquote.com/quotes/authors/o/ogden_nash.html> - "The trouble with a kitten is that when it grows up, it's always a cat." --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---