Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
fajaragungpramana committed Jan 27, 2021
2 parents 92154bf + f531e39 commit 30cbc66
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Android Field Input
[![](https://jitpack.io/v/fajaragungpramana/field-input.svg)](https://jitpack.io/#fajaragungpramana/field-input)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
</br>
</br>
Library for android, field input with drawable and click listener for drawable.
Library for android. FieldInput is layout component base on ViewGroup LinearLayout for get input from user.

## Installation
Add it in your root build.gradle at the end of repositories:
Expand All @@ -18,13 +19,14 @@ allProjects {
Add the dependency:
```gradle
dependencies {
implementation 'com.github.fajaragungpramana:field-input:0.0.2'
implementation 'com.github.fajaragungpramana:field-input:0.0.4'
}
```

## Usage
Define a view in your layout file:
```xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
Expand All @@ -38,34 +40,41 @@ Define a view in your layout file:
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
app:drawableEnd="@drawable/ic_barcode"
app:errorEnabled="false"
app:focusable="true"
app:hint="@string/app_name"
app:inputType="text"
app:passwordToggleEnabled="false"
app:textAllCaps="false"
app:textColor="@color/black"
app:textSize="14sp" />

</LinearLayout>
```
For drawable click listener.

Handle drawable click listener.
```kotlin
fieldInput.setOnClickDrawableListener(DrawablePosition.END) {
Log.d(MainActivity::class.simpleName, "Clicked!")
Log.d(MainActivity::class.simpleName, "Drawable ${DrawablePosition.END} Clicked!")
}
```

Get or do something when user is still typing text.
```kotlin
fieldInput.setOnTextChanged { text ->
// Do something hire when user still typing
}
```
For set error message.

Set error message.
```kotlin
fieldInput.errorMessage = "Type Something error message here!"
fieldInput.errorMessage = "Type something error message here!"
```
For set text or get text input.

Set or get text input.
```kotlin
fieldInput.text // Do this to get input
fieldInput.text = "Type something here!" // Do this to set input
```


## Preview
<a href="url"><img src="https://github.com/fajaragungpramana/assets/blob/master/FieldInput/fieldinput_preview.jpg" align="left" height="640" width="320" ></a>
</br>
Expand Down Expand Up @@ -101,10 +110,8 @@ fieldInput.text = "Type something here!" // Do this to set input
Attribute for FieldInput
| Attribute Name | Default Value | Description |
|----------------|---------------|-------------|
| hint | null | For set hint of field.
| errorEnabled | false | For activate error below field |
| hint | null | For set hint of field |
| focusable | true | For activate focus |
| passwordToggleEnabled | false | For activate password visibility |
| style | null | For set text appearance of text field |
| textAllCaps | false | For activate field text caps |
| drawableEnd | null | For put drawable in the right side |
Expand Down

0 comments on commit 30cbc66

Please sign in to comment.