protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); var input = FindViewById <EditText>(Resource.Id.ChatInput); var messages = FindViewById <ListView>(Resource.Id.ChatMessages); var adapter = new ResponseAdapter(this); messages.Adapter = adapter; Connector = new SignalConnector((Response response) => RunOnUiThread(() => { adapter.Add(response); })); Connector.JoinChat(); Button button = FindViewById <Button>(Resource.Id.ChatButton); button.Click += delegate { if (string.IsNullOrEmpty(input.Text)) { return; } Connector.Send(input.Text); input.Text = ""; }; }
public override void ViewDidLoad() { base.ViewDidLoad(); source = new MessagesDataSource(TableView); Connector = new SignalConnector((Response response) => InvokeOnMainThread(() => { source.Add(response); TableView.ReloadData(); })); Connector.JoinChat(); SendButton.TouchDown += (sender, e) => { if (string.IsNullOrEmpty(MessageTextField.Text)) { return; } Connector.Send(MessageTextField.Text); MessageTextField.Text = ""; MessageTextField.ResignFirstResponder(); }; MessageTextField.Delegate = new TextDelegate(); }