klinker41 / android-chips

Chips in your AutoCompleteTextView on Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I programmatically add chips to a RecipientEditTextView?

rnstewart opened this issue · comments

Thanks for this library; It's really well-done, and amazingly easy to use. I have a question though. Is there a way I can pre-populate a RecipientEditTextView with contacts? I.e., when I create my Activity or Fragment, I want to take a list of pre-existing names and phone numbers, and add them to the TextView as chips. Is this possible?

Thank you for your help!

Sure, just call submitItem() and pass it the correct information that you want to show in it as a chip.

Great! Thank you. This almost worked, but there is something odd about it.

So I have my RecipientEditTextView object, mTextContact, and I get a name and number to insert (both Strings). I call:

mTextContact.submitItem(name, number);

And what shows is an empty Chip. If I click on the chip, it populates with the name, but it doesn't show before that. Is there another function I need to call on mTextContact to complete the procedure?

Hello, did you ever solve this?

Call the submitItem within a OnGlobalLayoutListener of ViewTreeObserver.

mTextContact.getViewTreeObserver()