0

I would like to achieve an edit view that tags the text after a user has entered some text (in my case a phonenumber) and the user presses a comma. So for input that has Trevor Hansen, Alex Nelson, ... the output will be like this:

Courtesy: Google Material: Color Schemes

musale
  • 534
  • 8
  • 18

3 Answers3

2

Check out below library that serves what you want

Android chips with AutoComplete

Happy Coding! :)

Shrenik Shah
  • 1,900
  • 1
  • 11
  • 19
1

You can use these libraries:

AndroidTagView

EditTag

TagsEditText

Hadi
  • 159
  • 1
  • 9
0

Go through the below code, add a TextWatcher and your logic:

phoneNumber = (EditText) findViewById(R.id.phone);
tag = (TextView) findViewById(R.id.tag);

phoneNumber.addTextChangedListener(new TextWatcher() {

    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

    }

    @Override
    public void afterTextChanged(Editable editable) {

        String mobNo = editable.toString();

        if (mobNo != null && mobNo.length() >= 1) {

            if (mobNo.contains(",")) {
                mob = new SpannableString(mobNo.replace(",", ""));
                tag.setText(mob);
                phoneNumber.setText("");
            }
        }
    }
});

Add your logic for multiple data persistence.

Kurt Van den Branden
  • 11,995
  • 10
  • 76
  • 85
Joyal C Joseph
  • 290
  • 2
  • 12