more than one edittext in android - android

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.

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?

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.

Related

How to give an `EditText` a label to its left side?

How to give an EditText a label to its left side?
You can combine textview/imageview with edittext for that, for example like this one :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/shape_edittext_border_red"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView <!-- this one should be your text or image-->
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginLeft="10dp"
android:src="#drawable/your_logo" />
<EditText
android:id="#+id/edit_mobile"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#null"
android:hint="#string/dialog_mobile"
android:inputType="phone"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#color/main_color"
android:textColorHint="#color/main_color"
android:textSize="14sp" />
</LinearLayout>
you can do something like this.
File->new->image asset-> here choose 1st drop down and select Action bars and Tabs Icons->then choose radio button Asset type Text->now next columns is Text here in "Aa" field Enter "F" and choose back ground.
now save it with some img.png
now In your EditText
write add android:drawableLeft="#drawable/img.png" like bellow
<EditText
android:id="#+id/edittext_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Child's First Name"
android:textSize="20sp"
android:drawableLeft="#drawable/img.png" />

how to request focus on the second editText?

i want focus in the second editText ,also can make edit in the first
I have two edit text , i tried to put in the second edittext
android:focusable="true"
android:focusableInTouchMode="true"
but when tested it still focus in the firstEdit text
<EditText
android:id="#+id/editText1Price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/textView2"
android:ems="10"
android:inputType="numberDecimal" >
</EditText>
<EditText
android:id="#+id/editText2Funds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/textView4"
android:layout_toLeftOf="#+id/textView4"
android:ems="10"
android:focusable="true"
android:focusableInTouchMode="true"
android:inputType="number"
/>
this may little help you !
try this in your .java file :
EditText edittxt=(EditText)findViewById(R.id.editText2Funds);
edittxt.requestFocus();
Keep <requestFocus/> in the Second EditText.
try this,you have to add below code in which edittext you show focus..
<EditText...>
<requestFocus />
</EditText>

how to display editText(for scrolling) fill with String from the firts word, and not from the end?

i used edit text for scroll option, and it display text i wrote.
the problem is that when the activity whith this edit text open
it show the text from the end, and i need to scroll up to see the beginig
thans
this is the code (xml):
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView4"
android:layout_alignRight="#+id/imageView4"
android:layout_below="#+id/imageView4"
android:layout_marginTop="17dp"
android:background="#null"
android:cursorVisible="false"
android:editable="false"
android:ems="10"
android:gravity="top"
android:singleLine="false"
android:lines="8"
android:inputType="none"
android:
android:scrollbars="vertical"
android:text="Some Long String"
android:textColor="#android:color/white" >
You can set the cursor position in your Activity's onCreate() with setSelection():
EditText editText1 = (EditText) findViewById(R.id.editText1);
editText1.setSelection(0);
i used edit text for scroll option
If you only want to let the user scroll through your text, it is easier to use a ScrollView:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
... />
</ScrollView>

How to scroll the content of edittext when you click a button?

How to scroll the content of edittext when you click a button?
You can see the effect in a app called Calulator of android emulator.For example,when you input 'A+B' and then click the button named '=',the content of edittext scroll from 'A+B' to the result of 'A+B'.How to do it?Who can help me?
Here,thanks in advanceļ¼
Sorry!I'm a new programmer.I don't understand your reply a bit.How can I set the coordinates?I set like output.scrollBy(90,90),but it does't turn up a scroll view.
The following is my codes:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="80dip">
<EditText
android:id="#+id/input"
android:layout_gravity="top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:editable="false"
android:cursorVisible="false"
android:textSize="32dip"
android:singleLine="true"
android:focusable="false"
android:maxLength="17"
android:background="#drawable/image_et1_conf">
</EditText>
<EditText
android:id="#+id/output"
android:layout_gravity="bottom"
android:gravity="right"
android:ellipsize="none"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:editable="false"
android:cursorVisible="false"
android:textSize="32dip"
android:text="#string/output"
android:singleLine="true"
android:focusable="false"
android:maxLength="17"
android:background="#drawable/image_et2_conf">
</EditText>
</FrameLayout>
you should try using
editText.scrollby(scrollPixelInHorizontal,scrollPixelInVertical)
on onClickListener of Button

Android EditText keyboard newline not working (only on input view)

In the affirmation text field I press the newline button and it puts spaces.
However after I click done the field actually has the correct new lines (second screen capture).
Its not a problem with the device as it works correctly for the compose mail filed in the gmail app. Which is how I would like this to work.
<TextView
android:inputType="textMultiLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="#string/edit_affimation"
/>
<EditText
android:id="#+id/affText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp"
android:singleLine="false"
>
</EditText>
Figured it out
<EditText
android:inputType="textMultiLine"
android:id="#+id/affText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp"
android:singleLine="false">
</EditText>
Add following attribute:
android:inputType="textMultiLine"
You can also do it programmatically:
Editext txt = (EditText) findViewById(R.id.affText);
txt.setRawInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);

Categories

Resources