Android AutoCompleteTextView with '@' mentions filtering like twitter and facebook

The following method will extract words starting with "@":

private void parseText(String text) {
    String[] words = text.split("[ \\.]");
    for (int i = 0; i < words.length; i++) {
        if (words[i].length() > 0
                && words[i].charAt(0) == '@') {
            System.out.println(words[i]);
        }
    }
}

Once you have the words, use your auto complete filter and finally replace text using String.replace.


I ended up using the spyglass library from linkedin which does exactly what I was looking for. It provides a MentionsEditText (that can be customised). I also used a ListPopupWindow to show the suggestions in a list (like an AutoCompleteTextView).

Here is the link...

https://github.com/linkedin/Spyglass