That's because you change sText before it has been displayed, so the
sText is "Step three: serve egg" when mWaitRunnable is executed after
3 seconds.



On 23 Feb, 06:58, Michael Lam <[email protected]> wrote:
> hi,
>
> i am using handle and runnables to switch/change the content of the
> TextView using a "timer". for some reason, when running, the app
> always skips the second step ("Step Two: fry egg"), and only show the
> last (third) step ("Step three: serve egg").
>
> TextView t;
>         private String sText;
>
>         private Handler mHandler = new Handler();
>
>         private Runnable mWaitRunnable = new Runnable() {
>         public void run() {
>                 t.setText(sText);
>         }
>     };
>
>         @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>
>         setContentView(R.layout.main);
>
>         mMonster = BitmapFactory.decodeResource(getResources(),
>                         R.drawable.monster1);
>
>         t=new TextView(this);
>                 t=(TextView)findViewById(R.id.TextView01);
>
>                 sText = "Step One: unpack egg";
>                 t.setText(sText);
>
>                 sText = "Step Two: fry egg";
>                 mHandler.postDelayed(mWaitRunnable, 3000);
>
>                 sText = "Step three: serve egg";
>                 mHandler.postDelayed(mWaitRunnable, 4000);
>                 ...
>
>
>
> }

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