我想在MvxListView
內有EditText
,它有ItemLongClick
綁定正常工作(使用模板)。我使用的開發框架是Xamarin.Android中的MvvmCross
(寫在C#
)。MvxListVIew ItemLongClick與其中的EditText綁定
我試過了正常的方法,而EditText
似乎在MvxListView
項目中採取了所有的可重點操作。這意味着,ItemLongClick
只適用於該項目的EditText
部分。當我禁用EditText
(android:focusable="false"
),ItemLongClick
作品的所有部分(犧牲EditText
不能正常工作)時,知道何時禁用焦點很重要。我試過的最後一件事情是在我的項目佈局的根元素(基於this answer)上設置了android:descendantFocusability="blocksDescendants"
,它的作用與禁用可調焦的EditText
相同。
下面是我寫的代碼。
MvxListView在.axml
...
<Mvx.MvxListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
local:MvxItemTemplate="@layout/table_shipment_item_layout"
android:divider="#BCBCBC"
android:dividerHeight="1dp"
android:descendantFocusability="afterDescendants"
android:focusable="false"
local:MvxBind="ItemsSource ScannedItems; ItemLongClick RemoveItemCommand;" />
...
table_shipment_item_layout.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/custom_clickable_item">
...
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textSize="16.0dp"
android:text="5"
android:padding="8.0dp"
android:maxLines="1"
android:singleLine="true"
android:textColor="#000000"
android:textColorHint="#D3D3D3"
android:background="@drawable/custom_textbox"
android:inputType="number|numberDecimal"
android:digits="."
android:layout_gravity="right|center_vertical"
local:MvxBind="Text Quantity;" />
</LinearLayout>
正如你所看到的,我現在用的是EditText
,這樣用戶就可以編輯每個掃描項目的數量。有沒有解決方法?如果有的話,我也可以在MvxListView
以內的EditText
以外使用另一種方法。提前致謝。
是的,我已經嘗試了所有這些'descendantFocusability'並沒有那些作品。他們在那裏,因爲我多次嘗試後都沒有移除它。根據你的經驗,有沒有其他方法可以解決這個問題? –
看到我更新的答案。 –
感謝您的建議。是否有任何鏈接或教程使用'EditText'輸入'Dialog'?通過使用'ScrollView',它仍然會使用'local:MvxItemTemplate'和'ItemsSource'綁定嗎?如果是這樣,項目模板是否也會竊取父級的可聚焦性? –