android - EditText steals focus from other EditTexts inside ListView -
i have stand-alone edittext
, listview
. each item in listview has 2 edittext
fields. when touch inside listview
edittext
, stand-alone edittext
steals focus. makes impossible edit of listview
edittext
fields.
name
steals focus other textview
elements inside listview
here activity's xml, containing stand-alone edittext
, listview
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="16dip" android:orientation = "vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginbottom="16dip" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="16dip" android:layout_weight="1" android:text="@string/name" android:textappearance="?android:attr/textappearancemedium" /> <edittext android:id="@+id/editblindschedule_name" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="5" android:ems="10" android:inputtype="text" /> </linearlayout> <listview android:id="@+id/listview_editblindschedule" android:layout_width="match_parent" android:layout_height="wrap_content" /> </linearlayout>
and here listview
row 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" > <textview android:id="@+id/editblindschedule_round" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="2"/> <edittext android:id="@+id/editblindschedule_small" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/small" android:ems="4" android:inputtype="number" android:layout_weight="4" android:layout_marginright="10dip" android:text="@string/integer_zero" android:gravity="center" /> <edittext android:id="@+id/editblindschedule_big" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/big" android:ems="4" android:inputtype="number" android:layout_weight="4" android:layout_marginright="10dip" android:paddingright="6dip" android:text="@string/integer_zero" android:gravity="center" /> <checkbox android:id="@+id/editblindschedule_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:checked="true" /> </linearlayout>
here java code
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_edit_blind_schedule); ... adapter = new blindadapter(this, blindschedule.getblindlevels()); listview = (listview) findviewbyid(r.id.listview_editblindschedule); listview.setadapter(adapter);
and finally, adapter:
@override public view getview(int position, view convertview, viewgroup parent) { layoutinflater inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service); view row = inflater.inflate(r.layout.listview_editblindschedule, parent, false); if (!creating) { // set default values. textview round = (textview) row.findviewbyid(r.id.editblindschedule_round); edittext small = (edittext) row.findviewbyid(r.id.editblindschedule_small); edittext big = (edittext) row.findviewbyid(r.id.editblindschedule_big); round.settext("" + (position + 1)); small.settext("" + blindlevels.get(position).getsmallblind()); big.settext("" + blindlevels.get(position).getbigblind()); } return row; }
the solution worked me put android:windowsoftinputmode="adjustpan" in activity in manifest. change necessary me.
Comments
Post a Comment