Skip to main content

Components

Textfield

Used to enter spesific text input form

banner-Textfield

Usage

Textfields allow user input. The border should light up simply and clearly indicating which field the user is currently editing.

Basic

Here’s the default usage of Textfield with placeholder and label attribute set.

android basic

Xml Code

<com.telkom.legion.component.textfield.LgnSingleField
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
app:placeholderText="Email atau Username" />

Add TextChange Listener

with(binding) {
etEmail.doOnTextChanged { text, start, before, count ->
//Do your action here
}
}


Icon

android textfield icon

Xml Code

<com.telkom.legion.component.textfield.LgnSingleField
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Sample End Icon"
app:endIconDrawable="@drawable/ic_clock"
app:isOptional="true"
app:placeholderText="Email atau Username" />


Prefix & Suffix

prefix and suffix textfield

Xml Code

<com.telkom.legion.component.textfield.LgnSingleField
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Biaya"
app:helperText="Masukan Email dan Username anda!"
app:placeholderText="Email atau Username"
app:prefixText="Rp" />


Disabled

disabled textfield

Xml Code

<com.telkom.legion.component.textfield.LgnSingleField
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:enable="false"
app:placeholderText="Email atau Username" />


Error

android textfield error

Xml Code

<com.telkom.legion.component.textfield.LgnSingleField
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
app:placeholderText="Email atau Username" />

Kotlin Code

...
with(binding) {
etEmail.error = "Email sudah digunakan!"
}
...


Success

textfield success

Xml Code

<com.telkom.legion.component.textfield.LgnSingleField
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
app:placeholderText="Email atau Username" />

Kotlin Code

...
with(binding) {
etEmail.succcess = "Email bisa digunakan!"
}
...

Password Field

Here’s the password usage of Textfield with placeholder and label attribute set.

password field
password field

Static in xml

<com.telkom.legion.component.textfield.LgnPasswordField
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Kata Sandi"
app:placeholderText="Email atau Username" />

Dynamic using Kotlin*

...
with(binding) {
containerBase.addView( //ViewGroup for Dynamic Layout
LgnPasswordField(requiredContext()).apply {
//Your View's customization here
},
LinearLayout.LayoutParams( //For example we use viewgroup LinearLayout
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT

Date Field

Here’s the date picker usage of Textfield with placeholder and label attribute set.

date field
date field

Static in xml

<com.telkom.legion.component.textfield.LgnCalendarField
android:id="@+id/etCalendar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Tanggal Lahir"
app:dateFormat="FULL_DATE"
app:helperText="Pilih tanggal lahir anda!"
app:placeholderText="Tanggal Lahir" />

Dynamic using Kotlin*

...
with(binding) {
containerBase.addView( //ViewGroup for Dynamic Layout
LgnCalendarField(requiredContext()).apply {
//Your View's customization here
},
LinearLayout.LayoutParams( //For example we use viewgroup LinearLayout
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT

Time Field

Here’s the time picker usage of Textfield with placeholder and label attribute set.

time field
time field

Static in xml

<com.telkom.legion.component.textfield.LgnTimeField
android:id="@+id/etTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Waktu"
app:placeholderText="Waktu Budidaya" />

Dynamic using Kotlin*

...
with(binding) {
containerBase.addView( //ViewGroup for Dynamic Layout
LgnTimeField(requiredContext()).apply {
//Your View's customization here
},
LinearLayout.LayoutParams( //For example we use viewgroup LinearLayout
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT

Here’s the dropdown usage of Textfield with placeholder and label attribute set.

dropdown field
dropdown field

Static in xml

<com.telkom.legion.component.textfield.LgnDropdownField
android:id="@+id/etDropDown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Kategori"
app:helperText="Kategori Panen!"
app:isOptional="true"
app:placeholderText="Masukan Kategori Panen" />

Dynamic using Kotlin*

...
with(binding) {
containerBase.addView( //ViewGroup for Dynamic Layout
LgnDropdownField(requiredContext()).apply {
//Your View's customization here
},
LinearLayout.LayoutParams( //For example we use viewgroup LinearLayout
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT

Unit Field

Here’s the set of number field and dropdown field.

unit field
unit field

Static in xml

<com.telkom.legion.component.textfield.LgnSingleUnitField
android:id="@+id/etUnit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Luas Area"
android:inputType="number"
app:placeholderText="Masukkan luas area" />

Dynamic using Kotlin*

...
with(binding) {
containerBase.addView( //ViewGroup for Dynamic Layout
LgnSingleUnitField(requiredContext()).apply {
//Your View's customization here
},
LinearLayout.LayoutParams( //For example we use viewgroup LinearLayout
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT

Properties

Component NameIdDescription
TextViewtvHintTo display label on text area
TextInputLayoutetBaseTo display text field on text area
TextViewtvHelperTo display helper text on text area
TextViewtvErrorTo display error text on text area

Attributes

Attribute NameXml AttrsRelated method(s)Description
Textandroid:texttextTo set Text value directly via xml
Hintandroid:hinttextTo set Hint or Label value directly via xml
Enable Statusandroid:enabledisEnableTo set enable or disable text area directly via xml
Required Statusapp:isRequiredisRequiredTo set required status on text area directly via xml
Optional Statusapp:isOptionalisOptionalTo set optional status on text area directly via xml
Placeholder textapp:placeholderTextplaceHolderTo set placeholder text directly via xml
Helper textapp:helperTexthelperTo set helper text directly via xml
Suffix Text ¹app:suffixTextsuffixTextTo set suffix text on text field directly via xml
Prefix Text ¹app:prefixTextprefixTextTo set prefix text on text field directly via xml
Input Type ¹android:inputTypeinputTypeTo set input type on text field directly via xml
Start Icon Drawable ¹app:startIconDrawablestartIconDrawableTo set icon on front text field directly via xml
End Icon Drawable ¹app:endIconDrawableendIconDrawableTo set icon on behind text field directly via xml
Prefix End Icon Drawable ¹app:prefixEndIconDrawableprefixEndIconDrawableTo set icon on behind text prefix on text field directly via xml
Prefix Start Icon Drawable ¹app:prefixStartIconDrawableprefixStartIconDrawableTo set icon on front text prefix on text field directly via xml
Suffix End Icon Drawable ¹app:suffixEndIconDrawablesuffixEndIconDrawableTo set icon on behind text suffix on text field directly via xml
Suffix Start Icon Drawable ¹app:suffixStartIconDrawablesuffixStartIconDrawableTo set icon on front text suffix on text field directly via xml
Max Lines ¹android:maxLinesmaxLinesTo set maximum lines on text field directly via xml
Max Length ¹android:maxLengthmaxLengthTo set max length on text field directly via xml
Ellipsize Placement ¹android:ellipsizeellipsizeTo set where Ellipsize on text field directly via xml
Locked Field ¹N/AisLockedTo set locked field on LgnSingleField
Date Format ²app:dateFormatdateFormatTo set date format text directly via xml
Time Format ³app:timeFormattimeFormatTo set time format text directly via xml
Override Dropdown Behaviour ⁴ ⁵app:overrideDropdownoverrideDropdownTo override default behaviour of dropdown
Get Edit Text InstanceN/AeditTextTo get edit text instance from component
Add Values ⁴ ⁵N/AaddAll(List<String>)To set list of string to dropdown on component
Add Click Listener ⁴ ⁵N/AsetOnClickListenerTo set click listener on dropdown if you want override default behaviour
Add Dropdown Listener ⁴N/AsetListenerTo set listener on dropdown when value changed
Add Unit Listener ⁵N/AsetOnUnitListenerTo set listener on dropdown on unit field when value changed
Get Selected Unit Value ⁵N/AunitTo get selected unit on unit field
Get Edit Text on Dropdown Field Instance ⁵N/AdropDownTo get edittext on dropdown field instance on unit field