/Android-Prefix-Input

Adding a prefix to an EditText

Primary LanguageJavaMIT LicenseMIT

Android-Prefix-Input

Android Arsenal Release

Android library adding a prefix to an EditText.

gif

Gradle

allprojects {
   repositories {
      ...
      maven { url 'https://jitpack.io' }
   }
}
dependencies {
    ...
    compile 'com.github.bachors:Android-Prefix-Input:1.1'
}

Usage

<com.bachors.prefixinput.EditText
	android:id="@+id/foo"
	android:text="http://"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:inputType="text" />

<com.bachors.prefixinput.EditText
	android:id="@+id/bar"
	android:text="+62"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:inputType="number" />

Option

set text programmatically (dynamic)

<com.bachors.prefixinput.EditText
	android:id="@+id/username"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:inputType="text" />
...
import com.bachors.input.EditText
...
EditText username = (EditText) findViewById(R.id.username);

username.setPrefix("123_");

MIT