I want to customize an EditText which should have "constants" like in the picture below, so that I get the minutes and the seconds. (the number interface is irrelevant).
Asked
Active
Viewed 84 times
0
-
nothing so far because I don't know how to customize an EditText in code – mcjonesman May 08 '15 at 13:33
-
this is very simple just post here your views what actually you wants to do ... – Amitsharma May 08 '15 at 13:34
-
Masked Edit Texts views are not supported in Android, but there are external classes availble which modifies default behavior.. – Murtaza Khursheed Hussain May 08 '15 at 13:35
-
i m posting here is my answer for this – Amitsharma May 08 '15 at 13:36
-
amitsharma I don't understand what you mean..i just want an EditText what should look like this in the picture – mcjonesman May 08 '15 at 13:37
2 Answers
1
Try by this code this code are here i have try by this code .This code is working .
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_marginTop="50dp"
android:textColor="#000000"
android:background="#CCCCCC"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
>
<Button
android:id="@+id/btn0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0" />
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1" />
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3" />
<Button
android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4" />
<Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<Button
android:id="@+id/btn6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6" />
<Button
android:id="@+id/btn7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7" />
<Button
android:id="@+id/btn8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8" />
</LinearLayout>
show here is image below

Amitsharma
- 1,577
- 1
- 17
- 29
-
Sorry but as I said the number interface is irrelevant; I just want the line above as an EditText – mcjonesman May 08 '15 at 13:46
-
just add textview after edittext with height 2 dp with color black or kind of your color that you want.. – Amitsharma May 08 '15 at 13:47
0
First of all, I see no EditText on the screen you posted, that's plain TextViews that are updating on clicking the numbers.
Anyway, you could use multiple TextViews/EditTexts, which would allow you to easily change their formatting as well, or you could programatically change the formatting yourself. If you want to have a string resource that accepts parameters see here on how to do that.

Community
- 1
- 1

Evripidis Drakos
- 872
- 1
- 7
- 15
-
But I want an dynamic EditText in which the "constants" should be skipped when you type some numbers. So that it should look like "0m00s" in the beginning and when you type for example first 1, then 2 and then 0 it should look like "1m20s". – mcjonesman May 08 '15 at 13:45
-
You should look up what an EditText actually is. This is not an EditText. You want a simple TextView. By clicking on a number (button) you will change the TextView's text according to your needs. You could either do this by recalculating the text based on its old value and the new one pressed, or keep a list with the numbers enetered so you can create the text each time from that list. – Evripidis Drakos May 08 '15 at 13:48
-
If you really do want an EditText and just want to keep some formating while you type into it, look into implementing a TextWatcher : http://stackoverflow.com/questions/18305520/edittext-custom-string-formatting – Evripidis Drakos May 08 '15 at 13:51