AutoCompleteTextView (Beta): Tokens

In order to provide better user expirience and complete set of functionalities TKAutoCompleteTextView supports text tokenizing which can be enabled through the displayMode property of the TKAutoCompleteTextView.

this.Autocomplete.DisplayMode = TKAutoCompleteDisplayMode.Tokens;

The layout flow of the tokens can be horizontal or vertically wrapped. This feature can be accessed through the layoutMode property of the TKAutoCompleteTextView. By default vertical wrapping is used.

this.Autocomplete.LayoutMode = TKAutoCompleteLayoutMode.Wrap;

Tokens appereance can be customized by conforming to the TKAutoCompleteDelegate protocol and implementing the autocomplete:viewForToken: method. You can change variaty of properties to get custom look or you can provide a custom token object.

class AutoCompleteTokensDelegate : TKAutoCompleteDelegate
{
    public override TKAutoCompleteTokenView ViewForToken(TKAutoCompleteTextView autocomplete, TKAutoCompleteToken token)
    {
        TKAutoCompleteTokenView tokenView = new TKAutoCompleteTokenView(token);
        tokenView.BackgroundColor = UIColor.LightGray;
        tokenView.Layer.CornerRadius = 10;
        tokenView.ImageView.Layer.CornerRadius = 3;
        return tokenView;
    }
}