Numeric edittext loses focus after first input in listview - android

I have multiple edittexts in my listview, numeric and normal. When I click on a numeric it gets the focus and pops up the keypad but after I enter 1 number, it loses its focus and I have to click on it again to enter more numbers. Is there a way to keep focus so I can enter more numbers? My normal edittext works perfectly.
I have already tried with adjustpan and different keyboard modes.
edittext code:
<EditText
android:id="#+id/etEditTextItem"
android:inputType="number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_alignParentRight="true" />
Listview code:
<ExpandableListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/colorCard"
android:groupIndicator="#null">
</ExpandableListView>

The problem is the listview : you have to add the following to manifest in the listview activity
android:windowSoftInputMode="adjustPan"
and the following to listview
android:descendantFocusability="beforeDescendants"

I managed to fix it, after debugging the currentFocus i found out that the listview onExpand() took the focus away, setting editText.requestfocus() after returned the focus to the edittext.

I have the same issue, but my EditText is not in any ListView. It is simply inside several nested LinearLayouts and also looses its focus as for . What fixed my issue was to add TextChangedListener for this EditText in activity code and in onTextChanged I set:
EditText.requestFocusFromTouch()

Related

Strange behaviour of edittext when receiving focus

I have 2 layouts with EditText widget in them. In the first one EditText automatically receives focus on activity's start but shows no software keyboard (this is the desired behaviour). In the second layout, however, EditText is focused and shows soft-keyboard. I examined both layouts and can't find a reason for this behavour, because both widgets have identical properties. Soft-keyboard should only be displayed when I touch the input field. Am I missing something?
<EditText
android:id="#+id/scanLine"
android:layout_width="253.0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="19.0dp"
android:imeOptions="actionDone"
android:singleLine="true"
android:inputType="text"
android:maxLines="1"
android:focusableInTouchMode="true" />
Add the following line to the onCreate() method of your activity:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
Hope it helps!

Android multiline EditText

I've one EditText with multi-lines.
The problem is that, while I am adding more and more lines, just pressing ENTER or typing, the EditText keeps scrolling down which is OK, but after approx. 10 lines whole activity is scrolling.
And when I click again on EditText, the opened keyboard covers whole EditText.
But, when I click only on 3rd line, keyboard isn't covering EditText and View is moved like it should have.
Any advice please?
Okay,Using EditText in ScrollView Like this way
<ScrollView
android:layout_height="100dp"
android:layout_width="match_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#54D66A"
android:textSize="17sp" />
</ScrollView>
For programmatic approach please check
http://developer.android.com/reference/android/text/method/ScrollingMovementMethod.html
You can give android:maxHeight="60dp" to your EditText to stop scrolling of the whole Activity and it will solve other problem also.
I hope it helps.

Click on EditText won't show the keyboard?

I have a table whose tapping on a cell changes its content and displays some edit texts. The first of these edit texts requests the focus, but oddly when I tap on it, the keyboard doesn't show. It is when I tap the others edit texts though. What should I do? Here is how I implemented my first edit text.
<EditText
android:id="#+id/editContent"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:gravity="top"
android:inputType="textMultiLine" >
</requestFocus>
</EditText>
When I don't request the focus, there is also a strange behaviour: it opens the keyboard when I tap it but my edit text loses the focus and I've to tap it again to write in it.
I found the problem, it was because of this line in the Activity block of the Manifest :
android:windowSoftInputMode="stateHidden"
I changed it by :
android:windowSoftInputMode="adjustPan"
Works well now.

Android Edittext looses focus while typing in the keypad

I have one Edittext and there is a listview below of that edittext.Initailly Listview visibility set to GONE. Once user is typing in the edittext then I am making listview to Visible by populating refined results in the listview. But here after typing one letter in edittext, the edittext looses its focus. Again user needs to click on edittext and have to type to proceed. My question is how to make edittext not loosing focus when listview gets its visibity. Any help greatly appreciated.
just give in xml editext:
<EditText
android:id="#+id/editText1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textShortMessage" >
<requestFocus />
</EditText>
Set
edittext.requestFocus();
in the place where u are setting the listView visible..

Added text in EditText hosted by ListView row is removed upon keyboard closing

I use following GUI setup:
ListView activity
CursorAdapter that feeds this list
Layout for activity
Layout for rows in ListView :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity = "right" >
<TextView android:id="#+id/text_9_description_top"
android:layout_width="wrap_content"
android:layout_height="fill_parent" android:gravity="right|center_vertical"
android:layout_alignParentLeft="true">
</TextView>
<CheckBox android:id="#+id/chkApprovedTabChapter9"
android:layout_toRightOf="#+id/text_9_description_top"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:gravity="right" >
</CheckBox>
<Button android:id="#+id/tabchaprter9_row_button_delete"
android:layout_height="wrap_content" android:text="leftBtn"
android:layout_width="wrap_content" android:background="#android:drawable/ic_menu_delete"
android:layout_toRightOf="#+id/chkApprovedTabChapter9" >
</Button>
<Button android:id="#+id/tabchaprter9_row_button_edit"
android:layout_width="wrap_content" android:layout_toRightOf="#+id/tabchaprter9_row_button_delete"
android:text="rightBtn" android:layout_height="match_parent"
android:background="#android:drawable/ic_menu_edit">
</Button>
<EditText android:layout_width="wrap_content"
android:id="#+id/text_9_description_bottom"
android:layout_toRightOf="#+id/tabchaprter9_row_button_edit"
android:layout_height="match_parent" android:gravity="right"
android:layout_alignParentRight ="true"
android:inputType="text"
android:imeOptions="normal">
</EditText>
</RelativeLayout>
Row Layout contains EditText, checkbox and couple of buttons. ListView is filled with setAdapter (). Apparently ListView is created correctly, I see all rows with data.
First problem : I would like to initially show EditText as disabled so user cant edit text immediately. Only after clicking on "edit" button in the row EditText must became available for typing. Setting enable "false" has no effect on EditText (tried bot in code and in XML attribs) EditText is always editable.
Second issue: Typing in EditText using softkeyboard looks fine - I see all changes, however when I close softkeyboard (either pressing Android back button or "hide" button on keyboard) all added text is removed and EditText is reverted to its initial stage.
rather than enabling and disabling it try with focussable= "false" this will have desirable effect.
For first issue: add this attribute in XML file android:visibility="invisible"
And in the edit button onClickListener make the visibility as edit.setVisibility(View.VISIBLE).
make it clear for 2nd issue
first problem : you cannot disable EditText, write code to show TextView and hide EditText for disable EditText mode and vice versa for enable mode.
Second Problem: go to setting -> language and keyboard under text setting disable other languages and keep Android Keyborad on.

Categories

Resources