tags:

views:

141

answers:

4

Hi all.I receive data from udp server from my application.when i receive data i have to show that on the screen.I just use the Textview to display the incoming data(textview.setText("data")).But it displays the last incoming data only.I need to show the previous data also.how to solve this?

DatagramSocket clientsocket=new DatagramSocket(6363);
 byte[] receivedata=new byte[1024];
while(true)
{
DatagramPacket recv_packet=new DatagramPacket(receivedata, receivedata.length);
textview.setText("UDP S: Receiving...");
clientsocket.receive(recv_packet);
String rec_str=new String(recv_packet.getData());           
textview.setText(" Received String "+rec_str); 

}
} catch (Exception e) { } }

when i use append method it display's after all the incoming finished. I need to view when the data is coming at that time i have to show that.

+5  A: 

You can try using the append method from the TextView instead of setText

ccheneson
This is the way to go...
Ben
+1  A: 

To append something at the end of current content

textview.setText( "Recieved String " + textview.getText() +  rec_str);
primalpop
A: 

Can anybody help me using TextSwitcher for this problem..?

Tariq
A: 

try using

yourobject.invalidateViews();

to force an update

Chozabu