在聊天应用程序如何实现使用火力地堡

问题描述:

打字指标在聊天应用程序如何实现输入指示器有人在打字就像什么应用程序内使用火力地堡在聊天应用程序如何实现使用火力地堡

as shown in the Figure

+0

重复:https://stackoverflow.com/questions/33797431/how-to-determine-if-someone-is-typing-on-edittext –

为了实现这一目标或Messenger Android Studio中,您需要在Firebase数据库中添加一个新字段,名称为:typing,默认值为false。然后在EditText上使用addTextChangedListener()方法实际查看某人何时输入消息。当有人键入内容时,onTextChanged()方法被触发。现在将typing的值从false更改为true。在此之后,addValueEventListener查看值何时更改。如果该值为true,则在聊天室中显示该消息。所以,我建议你使用下面的代码:

yourEditText.addTextChangedListener(new TextWatcher() { 
    @Override 
    public void onTextChanged(CharSequence s, int start, int before, int count) { 
     if (!TextUtils.isEmpty(s)) { 
      //Set the value of typing field to true. 
     } else { 
      // Set to false 
     } 
    } 

    @Override 
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {} 

    @Override 
    public void afterTextChanged(Editable s) {} 
}); 
+0

我需要还有一个帮助如何在someOne正在输入数据库层次结构时更新isTyping,如下所示:https://firebasestorage.googleapis.com/v0/b/websolutionseo-8c349.appspot.com/o/Capture.PNG?alt=media&token = 3f78dfc5-ec33-40d1-AF19-e0853d0f2b5c – Arsalan