Answer the question
In order to leave comments, you need to log in
How to make permanent output of messages?
I accept messages, I want them to be constantly displayed in a list, for example, how best to do this?
For example, I just tried to display one in textview, but it does not display, although it works fine in winforms.
public class MainActivity : Activity
{
public string mess;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
StartListening ();
Button bt = FindViewById<Button>(Resource.Id.button1);
bt.Click += delegate { start();};
// Get our button from the layout resource,
// and attach an event to it
}
public void start()
{
TextView text = FindViewById<TextView> (Resource.Id.textView1);
StartListening();
text.Text = mess;
//text.SetText (mess);
}
private readonly UdpClient udp = new UdpClient(45000);
public void StartListening()
{
this.udp.BeginReceive(Receive, new object());
}
public void Receive(IAsyncResult ar)
{
IPEndPoint ip = new IPEndPoint(IPAddress.Any, 45000);
byte[] bytes = udp.EndReceive(ar, ref ip);
mess = Encoding.ASCII.GetString(bytes);
StartListening();
}
}
}
Answer the question
In order to leave comments, you need to log in
if you believe the code "output" it will only if you poke the button continuously and then only the last data from the variable that is constantly overwritten. The implementation of the idea is clearly incorrect, what exactly was planned to be done?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question