项目作者: Jantzilla

项目描述 :
Text field with automatic hints as you type.
高级语言: Java
项目地址: git://github.com/Jantzilla/AutoHintTextView.git
创建时间: 2019-02-02T18:33:24Z
项目社区:https://github.com/Jantzilla/AutoHintTextView

开源协议:Apache License 2.0

下载


AutoHintTextView

This library allows you to set custom suggestions for hint auto-complete!

How to

Gradle

  1. dependencies {
  2. implementation 'com.creativesource:autohinttextview:0.1.1'
  3. }

In your XML layout

  1. <com.creativesourceapps.android.AutoHintTextView
  2. android:id="@+id/tv_auto_hint"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content"
  5. android:padding="12dp"
  6. app:hint="Type a color"
  7. app:caseSensitive="false"
  8. android:entries="@array/colors"></com.creativesourceapps.android.AutoHintTextView>

Custom Attributes

Attribute Description
caseSensitive Whether or not text case is a suggestion factor
entries Location of suggestion resource array

In your Java code

  1. autoHintTextView = (AutoHintTextView) findViewById(R.id.tv_auto_hint);
  2. autoHintTextView.setCaseSensitive(false)
  3. autoHintTextView.setSuggestions(R.array.colors);
  4. autoHintTextView.addHintChangedListener(new TextWatcher() {
  5. @Override
  6. public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  7. // do stuff
  8. }
  9. @Override
  10. public void onTextChanged(CharSequence s, int start, int before, int count) {
  11. // do stuff
  12. }
  13. @Override
  14. public void afterTextChanged(Editable s) {
  15. // do stuff
  16. }
  17. });

Custom Methods

Method Description
setSuggestions(ArrayList<String> suggestions)
setSuggestions(int resId)
Sets custom hint suggestions
setCaseSensitive(Boolean boolean) Whether or not text case is a suggestion factor
addHintChangedListener(TextWatcher textWatcher) Listens to changes to suggestion hint
addTextChangedListener(TextWatcher textWatcher) Listens to changes to entry text

License

  1. Copyright 2019 Jantz Carney
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.