簡體   English   中英

滾動視圖中帶有edittext的Listview不可單擊

[英]Listview with edittext inside scrollview is not clickable

我有一個帶有edittext的listview作為scrollview內的行項。我在listview上使用了觸摸監聽器,因此可以在scrollview內滾動列表。但是無法調用onItemClickListenerOnItemSelectedListener 我嘗試了android:windowSoftInputMode =“ adjustPan”

<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <RelativeLayout
                android:id="@+id/rlHamburger"
                android:layout_width="50dp"
                android:layout_height="match_parent" >

                <Button
                    android:id="@+id/btnHamburger"
                    android:layout_width="35dp"
                    android:layout_height="35dp"
                    android:layout_centerInParent="true"
                    android:background="@drawable/images" />
            </RelativeLayout>

            <ScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_toRightOf="@+id/rlHamburger" >

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <RelativeLayout
                        android:id="@+id/rlTitle"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:layout_margin="5dp"
                        android:background="@drawable/relative_background" >

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerInParent="true"
                            android:layout_margin="10dp"
                            android:text="Add Quote"
                            android:textColor="@color/black"
                            android:textSize="20sp"
                            android:textStyle="bold" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/rlButtons"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:layout_below="@id/rlTitle"
                        android:layout_margin="5dp"
                        android:orientation="horizontal" >

                        <Button
                            android:id="@+id/btnBack"
                            android:layout_width="wrap_content"
                            android:layout_height="40dp"
                            android:layout_alignParentLeft="true"
                            android:layout_gravity="center_vertical"
                            android:layout_margin="5dp"
                            android:layout_weight="1"
                            android:background="@drawable/button"
                            android:gravity="center"
                            android:text="Back"
                            android:textColor="@drawable/text_color" />

                        <Button
                            android:id="@+id/btnAddPhoto"
                            android:layout_width="wrap_content"
                            android:layout_height="40dp"
                            android:layout_gravity="center_vertical"
                            android:layout_margin="5dp"
                            android:layout_toLeftOf="@+id/btnAddNote"
                            android:layout_weight="1"
                            android:background="@drawable/button"
                            android:gravity="center"
                            android:text="Add Photo"
                            android:textColor="@drawable/text_color" />

                        <Button
                            android:id="@+id/btnAddNote"
                            android:layout_width="wrap_content"
                            android:layout_height="40dp"
                            android:layout_gravity="center_vertical"
                            android:layout_margin="5dp"
                            android:layout_toLeftOf="@+id/btnSave"
                            android:layout_weight="1"
                            android:background="@drawable/button"
                            android:gravity="center"
                            android:text="Add Note"
                            android:textColor="@drawable/text_color" />

                        <Button
                            android:id="@+id/btnSave"
                            android:layout_width="wrap_content"
                            android:layout_height="40dp"
                            android:layout_alignParentRight="true"
                            android:layout_gravity="center_vertical"
                            android:layout_margin="5dp"
                            android:background="@drawable/button"
                            android:gravity="center"
                            android:text="Save"
                            android:textColor="@drawable/text_color" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/rlInformation"
                        android:layout_width="match_parent"
                        android:layout_height="180dp"
                        android:layout_below="@id/rlButtons"
                        android:layout_margin="5dp"
                        android:background="@drawable/relative_background"
                        android:orientation="horizontal"
                        android:padding="5dp" >

                        <RelativeLayout
                            android:id="@+id/rlInfo1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="2dp" >

                            <TextView
                                android:id="@+id/title"
                                android:layout_width="120dp"
                                android:layout_height="wrap_content"
                                android:layout_centerVertical="true"
                                android:text="Title" />

                            <EditText
                                android:id="@+id/tvTitle"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_toRightOf="@id/title"
                                android:background="@drawable/relative_background"
                                android:hint="Title"
                                android:padding="5dp" />
                        </RelativeLayout>

                        <RelativeLayout
                            android:id="@+id/rlInfo2"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/rlInfo1"
                            android:layout_margin="2dp" >

                            <TextView
                                android:id="@+id/owner"
                                android:layout_width="120dp"
                                android:layout_height="wrap_content"
                                android:layout_centerVertical="true"
                                android:text="Owner" />

                            <EditText
                                android:id="@+id/tvOwner"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_toRightOf="@id/owner"
                                android:background="@drawable/relative_background"
                                android:hint="Owner"
                                android:padding="5dp" />
                        </RelativeLayout>

                        <RelativeLayout
                            android:id="@+id/rlInfo3"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/rlInfo2"
                            android:layout_margin="2dp" >

                            <TextView
                                android:id="@+id/address"
                                android:layout_width="120dp"
                                android:layout_height="wrap_content"
                                android:layout_centerVertical="true"
                                android:text="Address" />

                            <EditText
                                android:id="@+id/tvAddress"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_toRightOf="@id/address"
                                android:background="@drawable/relative_background"
                                android:hint="Address"
                                android:padding="5dp" />
                        </RelativeLayout>

                        <RelativeLayout
                            android:id="@+id/rlInfo4"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/rlInfo3"
                            android:layout_margin="2dp" >

                            <TextView
                                android:id="@+id/status"
                                android:layout_width="120dp"
                                android:layout_height="wrap_content"
                                android:layout_centerVertical="true"
                                android:text="Status" />

                            <TextView
                                android:id="@+id/tvStatus"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_centerVertical="true"
                                android:layout_toRightOf="@id/status"
                                android:text="Status" />
                        </RelativeLayout>

                        <RelativeLayout
                            android:id="@+id/rlInfo5"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/rlInfo4"
                            android:layout_margin="2dp" >

                            <TextView
                                android:id="@+id/description"
                                android:layout_width="120dp"
                                android:layout_height="wrap_content"
                                android:layout_centerVertical="true"
                                android:text="Description" />

                            <EditText
                                android:id="@+id/tvDescription"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_toRightOf="@id/description"
                                android:background="@drawable/relative_background"
                                android:hint="Description"
                                android:padding="5dp" />
                        </RelativeLayout>
                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/rlList"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/rlInformation"
                        android:layout_margin="10dp" >

                        <TextView
                            android:id="@+id/tvProductName"
                            android:layout_width="200dp"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:text="Product Name" />

                        <TextView
                            android:id="@+id/tvShortDescription"
                            android:layout_width="200dp"
                            android:layout_height="wrap_content"
                            android:layout_toRightOf="@id/tvProductName"
                            android:gravity="center"
                            android:text="Short Description" />

                        <TextView
                            android:id="@+id/tvQuantity"
                            android:layout_width="100dp"
                            android:layout_height="wrap_content"
                            android:layout_toRightOf="@id/tvShortDescription"
                            android:gravity="center"
                            android:text="Qty" />

                        <TextView
                            android:id="@+id/tvUnits"
                            android:layout_width="100dp"
                            android:layout_height="wrap_content"
                            android:layout_toRightOf="@id/tvQuantity"
                            android:gravity="center"
                            android:text="units" />

                        <TextView
                            android:id="@+id/tvPrice"
                            android:layout_width="100dp"
                            android:layout_height="wrap_content"
                            android:layout_toRightOf="@id/tvUnits"
                            android:gravity="center"
                            android:text="Price" />

                        <TextView
                            android:id="@+id/tvTotal"
                            android:layout_width="200dp"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:gravity="center"
                            android:text="Total" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:id="@+id/rlList1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/rlList"
                        android:layout_margin="10dp" >

                        <ListView
                            android:id="@+id/lvItems"
                            android:layout_width="match_parent"
                            android:layout_height="300dp" >
                        </ListView>

                        <Button
                            android:id="@+id/btnAddItem"
                            android:layout_width="100dp"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/lvItems"
                            android:background="@drawable/button"
                            android:text="Add item"
                            android:textColor="@drawable/text_color" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/rlList1"
                        android:layout_margin="20dp" >

                        <TextView
                            android:id="@+id/tvTotalEstimation"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:gravity="center"
                            android:text="Total estimation"
                            android:textSize="20sp"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/tvEstimationValue"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_below="@id/tvTotalEstimation"
                            android:gravity="center"
                            android:text="$0.0"
                            android:textSize="20sp"
                            android:textStyle="bold" />
                    </RelativeLayout>
                </RelativeLayout>
            </ScrollView>
        </RelativeLayout>

這是我的布局的屏幕截圖:

在此處輸入圖片說明

請幫我解決問題。謝謝。

轉到清單文件,並使用您的班級的活動標簽添加以下步驟

android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM