I've been searching around but could not find any answers to this. What I'm trying to implement is an EditText similar to the 'To' field found in the composing screen of the ICS gmail app.
Here's an image describing what I want:
I'm thinking of extending EditText
and implementing my own custom EditText
class but I'm not really sure how to do that or even if that's the best solution. Any thoughts?
Adapted the solution from this answer. Separates the input automatically when inserting a comma (separator can be adjusted). Creates a an ImageSpan and a ClickableSpan (entries can be removed by clicking on the right part).
R.drawable.bordered_rectangle_rounded_corners:
Last thing to add is png for the "x-Button". Works well so far, only problem is that pressing long on the delete-key doesn't work (if someone has an idea how to make it work, feel free to comment)
I couldn't find a good solution, so I would up building my own library to handle this: TokenAutoComplete. Here's a basic example:
Layout code for contact_token (you'll need to find your own x drawable)
Token backgound drawable
Person object code
Sample activity
Layout code
Hm, took a while to find a similar question but nonetheless, here's the closest answer I found. I knew other people had this kind of problem before! Thanks to CommonsWare for pointing me in the right direction.