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

Reply via email to