Socket
Book a DemoInstallSign in
Socket

com.github.lamydev:android-spannedautocompleteview

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.lamydev:android-spannedautocompleteview

Android SpannedAutoCompleteView

Source
mavenMaven
Version
1.0
Version published
Maintainers
1
Source

Android SpannedAutoCompleteView

SpannedAutoCompleteView is a subclass of MultiAutoCompleteTextView.

The auto-complete text is converted into a image span.

Demo

Sample code is also available in this repository.

demo

Programming Guide

Compatibility

  • minSdkVersion: 11

Gradle

Android-SpannedAutoCompleteView library is pushed to Maven Central as a AAR, so you just need to declare the following dependency to your build.gradle.

dependencies {
    compile 'com.github.lamydev:android-spannedautocompleteview:1.0'
}

Span Layers

The image span is constructed by a stack of SpannAutoCompleteView#SpanLayer.

Background

The span background resides at the bottom of the span layer stack.

public void setSpanBackground(int resId);
public void setSpanBackground(Drawable drawable);

SpanLayer Construction/Destruction

To create a new span layer:

public SpanLayer createSpanLayer();

To destroy a span layer:

public void destroySpanLayer(SpanLayer layer);

SpanLayer Configuration (Methods of SpannedAutoCompleteView#SpanLayer)

To set a Drawable to a span layer:

public SpanLayer setDrawable(int resId);
public SpanLayer setDrawable(Drawable drawable);

To set gravity of a span layer (default is CENTER):

 ____________________________
|                            |
|            Top             |
|       --------------       |
|       |            |       |
|  Left |   Center   | Right |
|       |            |       |
|       --------------       |
|           Bottom           |
|____________________________|
public SpanLayer setGravity(int gravity);

To set margins of a span layer:

public SpanLayer setMargin(int l, int t, int r, int b);

Span Removal

To remove a span associated with the dropdownItem:

public void removeSpan(Object dropdownItem);

To remove a span automatically when the associated dropdownItem gets clicked:

public void setAutoRemove(boolean auto);

Tokenizer

By default, the tokenizer is automatically set up during view construction.

You don't need to consider about it. However, if you do, please remember that:

The parameter Tokenizer passed to setTokenizer MUST be an instance of SpannedAutoCompleteView#DefaultTokenizer.

Otherwise, exception IllegalArgumentException will be thrown.

Separator

By default, the separator is a white space ' '.

public void setSeparator(char separator);
public void setSeparator(CharSequence separator);

Callback

By setting a callback, you can monitor any events occurred on a span.

public void setCallback(Callback cb);

Called when the user clicks on a dropdownItem to complete the text:

void onSpanCreate(SpannedAutoCompleteView view, Object dropdownItem);

Called when a span is added:

void onSpanAdded(SpannedAutoCompleteView view, Object dropdownItem);

Called when a span is removed:

void onSpanRemoved(SpannedAutoCompleteView view, Object dropdownItem);

Called when the user clicks on a span:

void onSpanClick(SpannedAutoCompleteView view, Object dropdownItem);

Developers

  • Zemin Liu (lam2dev@gmail.com)

Any questions, contributions, bug fixes, and patches are welcomed. ^_^

License

Copyright (C) 2015 Zemin Liu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    
    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

FAQs

Package last updated on 28 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts