Oh ok..I think I understand it now.. On Thu, Jan 22, 2009 at 9:23 AM, Romain Guy <[email protected]> wrote:
> > The point of runOnUiThread() *is* to run code on the UI thread. > Therefore it must NOT be used for long running operations. Usually > runOnUiThread() is invoked from another thread. > > On Wed, Jan 21, 2009 at 7:50 PM, for android <[email protected]> wrote: > > any help on this ?? > > > > On Wed, Jan 21, 2009 at 8:13 PM, for android <[email protected]> > wrote: > >> > >> i have one question around the runOnUiThread...Basically when i used > this > >> method in the onCreate/onStart of the Activity,i found that it works > quite > >> differently than i expect.. > >> > >> For example in the onCreate/onStart..say I have long running operation > >> before which i want to render the UI with a progress bar.and after the > long > >> runnin operation is complete remove the progress bar and show the > view..In > >> this case I found that the UI is rendered only after the long running > >> operation...so i end up not seeing the progress bar..I ended up using > the > >> handler...Am i going wrong in my understanding of this method? > >> > >> > >> > >> protected void onStart(){ > >> super.onStart(); > >> ////Progress Bar Visible > >> runOnUiThread( new Thread() { > >> // go get our feed! > >> public void run() { > >> //longrunning operation > >> //Progress Bar Gone > >> //show the required view > >> > >> } > >> }); > >> } > >> > >> On Wed, Jan 21, 2009 at 7:55 PM, Mark Murphy <[email protected]> > >> wrote: > >>> > >>> Nico wrote: > >>> > Hi, > >>> > I need to replace the current View (set by the > activity.setContentView > >>> > method) by an other. > >>> > When I call activity.setContentView two times, I get this exception : > >>> > 01-21 14:13:54.747: WARN/System.err(1156): android.view.ViewRoot > >>> > $CalledFromWrongThreadException: Only the original thread that > created > >>> > a view hierarchy can touch its views. > >>> > 01-21 14:13:54.757: WARN/System.err(1156): at > >>> > android.view.ViewRoot.checkThread(ViewRoot.java:1849) > >>> > 01-21 14:13:54.757: WARN/System.err(1156): at > >>> > android.view.ViewRoot.requestLayout(ViewRoot.java:455) > >>> > 01-21 14:13:54.767: WARN/System.err(1156): at > >>> > android.view.View.requestLayout(View.java:6575) > >>> > 01-21 14:13:54.767: WARN/System.err(1156): at > >>> > android.view.View.requestLayout(View.java:6575) > >>> > 01-21 14:13:54.777: WARN/System.err(1156): at > >>> > android.view.View.requestLayout(View.java:6575) > >>> > 01-21 14:13:54.777: WARN/System.err(1156): at > >>> > android.view.ViewGroup.removeAllViews(ViewGroup.java:2033) > >>> > What is problem ? > >>> > >>> As the exception says: "Only the original thread that created > >>> a view hierarchy can touch its views". > >>> > >>> Are you attempting to call setContentView() from a background thread? > If > >>> so, arrange to call it on the UI thread, via post(), runOnUiThread(), > or > >>> a Handler. > >>> > >>> -- > >>> Mark Murphy (a Commons Guy) > >>> http://commonsware.com > >>> Android Training in Sweden -- http://www.sotrium.com/training.php > >>> > >>> > >> > > > > > > > > > > > > > -- > Romain Guy > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

