问题
I have a Listview with row layout contains two textviews and a edittext In my activity i use
android:windowSoftInputMode="adjustResize|stateHidden"
and in edittext arguments are:
<EditText
android:id="@+id/et_quantity_test"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:inputType="numberSigned"
android:gravity="center_vertical|left"
android:layout_gravity="center_vertical|left"
android:paddingLeft="3dp"
android:imeOptions="actionNext"
android:layout_marginRight="10dp"
></EditText>
The problem : When i click on edittext the keyboard shows but edittext field lost focus and the keyboard type is alphabetic ,not numeric.. Thanks
That is main layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<ImageButton
android:id="@+id/img_back"
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:layout_height="wrap_content"
android:src="@drawable/navigation_back"
android:layout_alignParentRight="true"/>
<TextView
android:id="@+id/tv_title_testing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/test_title"
android:gravity="center_vertical"
android:layout_centerInParent="true"
android:textAppearance="@android:style/TextAppearance.Holo.Medium"
/>
</RelativeLayout>
<Chronometer
android:id="@+id/chronometer_testing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.65"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:gravity="center_horizontal|center_vertical"
android:text="@string/test_sub_title"
android:textAppearance="@android:style/TextAppearance.Holo.Medium" />
</LinearLayout>
<!-- <RelativeLayout
android:layout_height="match_parent"
android:layout_width="fill_parent"> -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ListView
android:id="@+id/lv_product_items_testing"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="9"
transcriptMode="alwaysScroll"
android:scrollbars="vertical" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/ll_conf"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_confirm_test_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_gravity="center_horizontal"
android:text="@string/test_conf" />
<Button
android:id="@+id/btn_confirm_report"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_gravity="center_horizontal"
android:text="@string/test_report" />
</LinearLayout>
</LinearLayout>
回答1:
First write down android:windowSoftInputMode="adjustPan"
in Activity in Manifest file to set listview and Edittext and delete android:inputType="numberSigned"
from Edittext is help to When you click EditText keyboard open with Alphabetic..
来源:https://stackoverflow.com/questions/12860020/issue-with-edittext-in-listview-softkeyboard