4

I want to make a input pin code input box as per below image .i have used four edittext for it but my problem is that i m unable to move the cursor from one edittext to other and vice-versa.Please help me on this.enter image description here

user853341
  • 149
  • 2
  • 12

2 Answers2

0

I think something like this will do what you want:

<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<EditText
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" >


</EditText>
 <EditText
    android:id="@+id/editText2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" >


</EditText>
<EditText
    android:id="@+id/editText3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" >


</EditText>
<EditText
    android:id="@+id/editText4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" >


</EditText>

Or do you want to auto-jump from one EditText to another when filled?

ArcDare
  • 3,106
  • 4
  • 27
  • 38
0

what do you mean you are unable to "move the cursor from one edittext to other and vice-versa" ??

Like when you type in one character/number in the edit text so the cursor should jump to next edittext?

If so try getFocus() with implementation a TextWatcher for the EditText, it has a callback that gets called after every letter typed in.

Alone89
  • 307
  • 1
  • 12
  • can i use same textwatcher for all edittext in that case how could i set the cursor position? – user853341 Nov 02 '11 at 10:06
  • the textWatcher knows which view/edittext called him, so just get view.getId() and make switch-case code alias "if (id = 1) edittext2.getfocus(); if (id=2) edittext3.getfocus(); etc. – Alone89 Nov 02 '11 at 10:23
  • np, if it doesn't work write it here so maybe someone else will save a time knowing that this is not the solution ;-) On the other hand dont forget to mark as the best answer if it works :)) – Alone89 Nov 02 '11 at 10:31