private void InitViews() { UserMessage = FindViewById <EditText>(Resource.Id.main_inputmessage_edittext); SendButton = FindViewById <Button>(Resource.Id.main_send_floatingactionbutton); MessagesRecycler = FindViewById <RecyclerView>(Resource.Id.main_message_listview); TextInputLayout = FindViewById <RelativeLayout>(Resource.Id.main_textinput_layout); ButtonsInputLayout = FindViewById <HorizontalScrollView>(Resource.Id.main_buttoninput_layout); InputArea = FindViewById <LinearLayout>(Resource.Id.main_inputmessage_layout); Adapter = new ChatAdapter(MessagesList); var layoutManager = new LinearLayoutManager(this); layoutManager.ReverseLayout = true; layoutManager.StackFromEnd = true; MessagesRecycler.SetLayoutManager(layoutManager); MessagesRecycler.SetAdapter(Adapter); SendButton.Enabled = false; SetInputLayout(true); var activity = new Microsoft.Bot.Connector.DirectLine.Activity("message", text: "Hey, my name is Thuan, I'll help you get this claim sorted out in no time...", fromProperty: new Microsoft.Bot.Connector.DirectLine.ChannelAccount { Id = BotConnector.BotId }); AddMessageToList(activity); }
private void AddMessageToList(Microsoft.Bot.Connector.DirectLine.Activity message) { MessagesList.Insert(0, message); Adapter.NotifyItemInserted(0); MessagesRecycler.ScrollToPosition(0); }