android - Edittext inside ExpandableListView does not show keyboard -
i have custom dialogfragment thats displays expandablelistview , items edittext. when edittext gets focus input keyboard not shown, if force code using inputmethodmanager.forced flag.
dialogfragment 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" android:descendantfocusability="afterdescendants" > ... <expandablelistview android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" android:descendantfocusability="afterdescendants" /> <textview android:id="@android:id/empty" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ff0000" android:text="@string/no_calculations"/> </linearlayout>
item xml of expanded list:
<?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:padding="10dp" android:background="#ffffff" > ..... <edittext android:id="@+id/edittextpercentage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="160dp" android:layout_marginleft="16dp" android:layout_toleftof="@id/percentagesymbol" android:inputtype="numberdecimal" android:textcolor="#000000" android:layout_centervertical="true" android:maxlength="8" android:maxlines="1" android:focusable="true" android:focusableintouchmode="true" android:text="@string/default_percentage_calculations" > </edittext> </relativelayout>
manifest.xml:
<activity android:windowsoftinputmode="adjustpan">
even forcing keyboard, not work:
final edittext percentage=(edittext) convertview.findviewbyid(r.id.edittextpercentage); percentage.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { inputmethodmanager imm = (inputmethodmanager) getactivity().getsystemservice(context.input_method_service); imm. showsoftinput (percentage, inputmethodmanager. show_forced); return false; } });
any idea how can show keyboard?
i found workaround, trick because don't know why work. added dummy invisible edittext @ beginning of dialogfragment 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" android:descendantfocusability="afterdescendants" > <edittext android:id="@+id/dummyedittext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputtype="numberdecimal" android:enabled="false" android:visibility="gone" /> ......
Comments
Post a Comment