Movies FUn :
This the code that I've written but I am getting the full string and the function is only triggered if the first character is @. I want it to check for every instance of @ and whenever the @ key is pressed i want to open the dialog. I tried using the onKeyDown()
but couldn't make it work.
override fun afterTextChanged(editable: Editable?) {
viewModel.onDoubtTextChanged(editable.toString())
if (editable.toString() == "@") {
openUserSuggestionDialog(doubtDescription.users as ArrayList<User>,viewModel)
}
editable
contains the value which is being inputted into the TextView
whiterabbitj :
Add a on TextChange Listener to your editText
editable.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//get the last String entered
String lala = editable.getText().toString();
String subChar = lala.substring(lala.length() - 1);
if(subChar.equals("@"))
openUserSuggestionDialog(doubtDescription.users as ArrayList<User>,viewModel)
}