Dear all,

I made an android application that receives XMPP messages (using the
Smack library). Each time a message is received, the body of this
message should be placed inside a TextView. However, only when
receiving the first message this TextView is updated. When debugging
the application, I saw messages are received correctly but the
TextView is not updated properly. Currently, I am using setText() to
place the message content inside the textview.

Below, you can find the most relevant code of my program.

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayout lin = new LinearLayout(this);
        lin.setOrientation(LinearLayout.VERTICAL);
        TextView m_tv = new TextView(this);
        m_tv.setId(1000);
        m_tv.setWidth(250);
        lin.addView(cl);

        setContentView(lin);

        initXMPPService(); //Initialize XMPP and XMPP callback
    }

private void initXMPPService() { ... }

//XMPP Callback
public void processMessage(Chat arg0, Message arg1) {
        TextView tv = (TextView)this.findViewById(1000);
        // set the text to the textview
        tv.setText(arg1.getBody());
        // debug: shows that the messages are received correctly
        Log.i("XMPPCLient", "Got message "+arg1.getBody());
 }
}

Hopefully someone can help me out.

Kind regards,

Jan Meskens

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