Solved.
Created new Runnable with t.setVisibility(4). Then as suggested, added
removeCallbacks() and it works perfectly.
Thank you!

M

On Jul 7, 1:55 pm, Mark Murphy <[email protected]> wrote:
> Use removeCallbacks() to get rid of your posted Runnable when it is no
> longer valid, and schedule a fresh one.
>
>
>
>
>
>
>
>
>
> On Thu, Jul 7, 2011 at 7:37 AM, MG <[email protected]> wrote:
> > Hi!
> > I have a problem. I am developing an app where I get some message
> > (html text) and display it in TextView. Comunication is based on JADE
> > and JADE-Android, but problem is not here. I can send and recieve
> > messages OK.
> > I need my TextView to disapear after some time (let say 10s) if there
> > is no new messages recieved. I tried Thread.sleep() but that stops the
> > whole thing and I don't want that. I also tried Handler.postDelayed()
> > and it works to some extent. Problem is, it hides TextView in any
> > case, even if new message is recieved before 10s is over. I need it to
> > hide only if there is no new message. How can I accomplish this?
>
> > Thanks for any help!
>
> > Here is the part of the code that is relevant.
>
> > In my main Activity, I create method updateText(String) -
>
> > public void updateText(String text) {
> >                t = (TextView) findViewById(R.id.textView1);
> >                t.setVisibility(0);
> >                t.setText(Html.fromHtml(text));
> > //              textViewHandler.removeCallbacksAndMessages(textViewHandler);
> >            textViewHandler.postDelayed(new Runnable() {
> >                 public void run() {
> >                         t.setText("Handler");
> >                         t.setVisibility(4);
> >                 }
> >            }, 10000);
> >        }
>
> > In another class I call this method, when new message is recieved -
>
> > public void onMessageReceived(ACLMessage msg) {
> >                // TODO Auto-generated method stub
> >                MyUpdater up = new MyUpdater(act, msg);
> >                handl.post(up);
> >        }
>
> >        private class MyUpdater implements Runnable {
>
> >                ACLMessage msg;
> >                CaptureActivity act;
>
> >                public MyUpdater(CaptureActivity sm, ACLMessage msg) {
>
> >                        this.msg = msg;
> >                        this.act = sm;
> >                }
>
> >                public void run() {
>
> >                        act.updateText("<b>**Sporočilo agenta "
> >                                        + msg.getSender().getLocalName() + 
> > ":**</b><br/><br/>"
> >                                        + msg.getContent());
>
> >                }
> >        }
>
> > --
> > 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
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android Training...At Your Office:http://commonsware.com/training

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