Assuming that is in the main thread then the runnable for display
updates and layout changes is not going to get a chance to run until
after your synchronous  loop exists. You need to either split your
logic up into chunks and use Handlers posted into the main ui thread
or move your logic into a worker thread ( where you will need to post
the updates back to the ui thread with a handler )

Basically read through the source for handlers and how the update and
layouts ui code works...

Hope that helps
David


On Sep 6, 10:21 am, Francesco Pace <[email protected]> wrote:
> Hello Lance,
> Thanks for you answer. I try with you code but my program doesn't work
> correctly. It show me strings but all together at the end of my activity.
>
> For example, I have:
>
>        View.OnClickListener mStartListener2 = new OnClickListener() {
>             public void onClick(View v) {
>                 for(int i=0;i<1000;i++) {
>                     mText.append("mytext " + i + "\n);
>
>                     mScroll.post(new Runnable() {
>                             public void run() {
>                                 mScroll.fullScroll(ScrollView.FOCUS_DOWN);
>                             }
>                     });
>                 }
>             }
>         };
>        mButton.setOnClickListener(mStartListener2);
>
> Then I start my application.
> When I press mButton my program doesn't write strings "in real time" (mytext
> 1 , mytext 2, etc etc) but show me all at the end of activity.
> Sorry for my english, I'm an italian student.
> Can you help me?
>
> Thanks,
> Francesco
>
> 2009/9/6 Lance Nanek <[email protected]>
>
>
>
> > Not sure exactly what problem you are seeing. If you want separation
> > between the things you append, then append some extra space or line
> > feeds like this:
>
> > mTextView.append("\n");
> > mTextView.append(mText);
>
> > If you want to replace the things that were previously in the
> > TextView, then use the setText method:
>
> > mTextView.setText(mText);
>
> > If you want the ScrollView to properly account for the things you just
> > added and go all the way down to the bottom then use this monstrosity:
>
> > mScrollView.post(new Runnable() {
> >        public void run() {
> >                mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
> >        }
> > });
>
> > On Sep 5, 3:58 pm, Francesco Pace <[email protected]> wrote:
> > > Up!
>
> > > 2009/9/5 Francesco Pace <[email protected]>
>
> > > > Hi developers,
> > > > I have a question.
> > > > In my android application I have a TextView in a ScrollView.
>
> > > > I want to update TextView dinamically and I write this statement :
>
> > > > mTextView.append(mText);
> > > > mScrollView.pageScroll(ScrollView.FOCUS_DOWN);
>
> > > > and so my application works.
> > > > Unfortunately the strings that I have to insert are shown ALL TOGETHER
> > at
> > > > the end of application.
> > > > Can anyone help me?
>
> > > > Thanks.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to