android - EditText looses focus when keyboard appears; requires touching twice to edit -
android - EditText looses focus when keyboard appears; requires touching twice to edit -
i have been designing application holds expandable list. @ end of every list, empty edittext
ready receive comments. have next problem; when touch edittext
, screen resizes (not problem resizing not happen, depending on layout , position of edittext
int list) , soft-keyboard appears. however, during these events, edittext
looses focus , not regain it. quite inconvenient without focus, despite keyboard beingness available, input keyboard not reach edittext
. 1 time touch again, edittext
behaves expected.
it gets stranger. keyboard still displayed, can touch different edittext
, same happens; looses focus. however, 1 time passed initial loss of focus, can move freely between touched edittext
s without focus related issues. when hide soft-keyboard "state" disappear , need tap edittext
s twice before beingness able edit them.
here excerpts code. first, empty_comment.xml
:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <edittext android:id="@+id/blank_box" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputtype="textcapsentences" android:imeoptions="actiondone" android:hint="@string/hint" android:layout_marginleft="30dip" > </edittext> </linearlayout>
here excerpt fragment utilize layout in question:
convertview = layoutinflater.from(parent.getcontext()).inflate(r.layout.comment_empty, null); final edittext edittext = (edittext) convertview.findviewbyid(r.id.blank_box); edittext.setoneditoractionlistener(new oneditoractionlistener() { @override public boolean oneditoraction(textview v, int actionid, keyevent event) { if(actionid == editorinfo.ime_action_done) { // unrelated code } homecoming true; } });
i not specifying input specific in manifest file provide if deemed helpful.
update:
adding line activity
adjust pan android:windowsoftinputmode="adjustpan"
partially solve problem. replaces current unexpected behaviour problem edittext
views might hidden soft-keyboard.
as of now, no ideal solution has been found approached. have @ comments in accepted answer, might prove useful you!
you need alter in androidmanifest.xml
add android:windowsoftinputmode="adjustpan"
in activity holding listview. solve problem.
<activity android:name=".myedittextinlistview" android:label="@string/app_name" android:windowsoftinputmode="adjustpan">
android focus android-edittext
Comments
Post a Comment