EditText In ListView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/main"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<!-- Header -->
<LinearLayout android:id="@+id/header"
android:background="#FFFFFF"
android:padding="10dip"
android:orientation="horizontal"
android:paddingBottom="5dip"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
<TextView android:id="@+id/heading"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Items"
android:gravity="left"
android:layout_weight="1"
android:textColor="#CC6633"
android:textSize="25px"
android:textStyle="bold"
/>
<Button
android:text="Add To Order"
android:id="@+id/btnOrder"
android:layout_weight="1"
android:textSize="15px"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_he开发者_开发问答ight="wrap_content">
</Button>
</LinearLayout>
<LinearLayout android:id="@+id/header"
android:background="#FFFFFF"
android:padding="5dip"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:padding="5dip"
android:id="@+id/linearLayout2">
<TextView
android:id="@+id/txtnameItem"
android:text="Item"
android:gravity="left"
android:textColor="#000000"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:padding="5dip"
android:gravity="left"
android:id="@+id/linearLayout2">
<TextView
android:id="@+id/txtpriceItem"
android:gravity="left"
android:text="Price"
android:layout_weight="1"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="left">
</TextView>
<TextView
android:id="@+id/txtorderItem"
android:gravity="right"
android:text="Order"
android:layout_weight="1"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right">
</TextView>
</LinearLayout>
</LinearLayout>
<!-- List Divider -->
<View android:layout_width="fill_parent"
android:layout_height="5dip"
android:background="#C85A17" />
<!-- ListView (list_items) -->
<LinearLayout android:id="@+id/layout"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<ListView android:id="@+id/listview"
android:layout_height="wrap_content"
android:clickable="true"
android:descendantFocusability="beforeDescendants"
android:layout_width="fill_parent">
</ListView>
</LinearLayout>
</LinearLayout>
finalorderitem.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF"
android:layout_height="fill_parent">
<LinearLayout
android:layout_margin="15dip"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#FFFFFF"
android:orientation="horizontal"
android:id="@+id/linearLayout1">
<LinearLayout
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:padding="3dip"
android:paddingRight="0dip"
android:id="@+id/linearLayout2">
<TextView
android:id="@+id/txtnameFinalOrderItem"
android:textSize="20px"
android:textStyle="bold"
android:text="col_1"
android:gravity="left"
android:textColor="#000000"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:textStyle="bold"
android:id="@+id/linearLayout2">
<EditText
android:text=""
android:id="@+id/edttextFinalOrderQty"
android:layout_width="fill_parent"
android:layout_weight="1"
android:onClick="setFocus"
android:numeric="integer"
android:layout_height="wrap_content">
</EditText>
<TextView
android:id="@+id/txtfinalpriceFinalOrderItem"
android:gravity="left"
android:layout_gravity="center"
android:text="col_2"
android:layout_weight="1"
android:textSize="20px"
android:textColor="#000000"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
so now i make a CustomAdapter which extends BaseAdapter class, all things work very fine, list view appear correctly, but whenever i click on edittext to enter some value then it lost his focus due to getView() function, so please suggest me what can i do for this
You can add a windowSoftInputMode description in the AndroidManifest.xml file:
<activity
android:name= "YourActivityName"
android:windowSoftInputMode="adjustPan"
/>
精彩评论