Android SpannedAutoCompleteView


License

License

Categories

Categories

Auto Application Layer Libs Code Generators
GroupId

GroupId

com.github.lamydev
ArtifactId

ArtifactId

android-spannedautocompleteview
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

aar
Description

Description

Android SpannedAutoCompleteView
Android SpannedAutoCompleteView
Project URL

Project URL

https://github.com/lamydev/Android-SpannedAutoCompleteView
Source Code Management

Source Code Management

https://github.com/lamydev/Android-SpannedAutoCompleteView

Download android-spannedautocompleteview

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.lamydev/android-spannedautocompleteview/ -->
<dependency>
    <groupId>com.github.lamydev</groupId>
    <artifactId>android-spannedautocompleteview</artifactId>
    <version>1.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.lamydev/android-spannedautocompleteview/
implementation 'com.github.lamydev:android-spannedautocompleteview:1.0'
// https://jarcasting.com/artifacts/com.github.lamydev/android-spannedautocompleteview/
implementation ("com.github.lamydev:android-spannedautocompleteview:1.0")
'com.github.lamydev:android-spannedautocompleteview:aar:1.0'
<dependency org="com.github.lamydev" name="android-spannedautocompleteview" rev="1.0">
  <artifact name="android-spannedautocompleteview" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.lamydev', module='android-spannedautocompleteview', version='1.0')
)
libraryDependencies += "com.github.lamydev" % "android-spannedautocompleteview" % "1.0"
[com.github.lamydev/android-spannedautocompleteview "1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
com.android.support » appcompat-v7 jar 22.0.0

Project Modules

There are no modules declared in this project.

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

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.

Versions

Version
1.0