【发布时间】:2017-12-20 23:36:09
【问题描述】:
在我的 Xamarin 应用程序中,我需要有 3 个水平对齐的列表视图。我需要 3 个列表,因为我需要能够独立单击列表中的项目(例如,我可以单击第一个列表的第二行并使该单元格更改颜色并对第三个列表的第五行执行相同操作) . 但我需要列表始终对齐,即使我滚动一个列表。
假设您在中间的列表中列出了我们销售的产品。左侧列表显示代理 A 对该产品的数量和价格,而右侧列表显示代理 B。
现在客户可以查看中间列表中的产品,对应该行,其他两个列表(在同一行)将显示我们的 2 个代理申请该产品的价格和数量有可用的。
然后,如果客户想从他那里购买该产品,则可以单击代理 A 的列表行,并且他可能会单击代理 B 列表的另一行从他那里购买另一种产品。
每次单击时,相应的单元格都会改变颜色,以便为客户提供概览。然后,一旦他完成了,他将单击一个按钮并向我们发送订单。 所以基本上用户需要能够独立处理列表,如果滚动查看更多产品,重要的是 2 个代理的列表将同步滚动以确保用户看到正确的价格和中间列表的给定行中该产品的数量。
我有以下内容,您可以看到我已将 3 个列表视图置于水平方向的线性布局中。如何确保列表在 Xamarin 中同步滚动?我看到了一些关于 Java 的其他问题,但我不知道如何将这些解决方案用于 Xamarin。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:id="@+id/llContainer">
<View
android:layout_height="2dp"
android:layout_width="match_parent"
android:background="#000" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:background="#009acd">
<TextView
android:text="Call"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:gravity="center"
android:textColor="#000"
android:textStyle="bold"
android:textSize="16sp" />
<TextView
android:text="Strike"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:gravity="center"
android:textColor="#000"
android:textStyle="bold"
android:textSize="16sp" />
<TextView
android:text="Put"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:gravity="center"
android:textColor="#000"
android:textStyle="bold"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_height="2dp"
android:layout_width="match_parent"
android:background="#000" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:background="#009acd">
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/mListView1"
android:divider="#00000000"
android:dividerHeight="1dp" />
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/mListView2"
android:divider="#00000000"
android:dividerHeight="1dp" />
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/mListView3"
android:divider="#00000000"
android:dividerHeight="1dp" />
</LinearLayout>
</LinearLayout>
【问题讨论】:
-
这些答案似乎不适用于 Xamarin。
标签: c# xamarin xamarin.forms xamarin.ios xamarin.android