【问题标题】:Make more listviews to scroll in sync in a Xamarin app使更多列表视图在 Xamarin 应用程序中同步滚动
【发布时间】: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>

【问题讨论】:

标签: c# xamarin xamarin.forms xamarin.ios xamarin.android


【解决方案1】:

随着虚拟化和列表的所有魔力,我认为这将很困难并且可能不可靠。

IMO 你最好拥有一个列表并独立管理手势和单元格颜色等

希望对你有帮助

【讨论】:

  • 我添加了更多关于为什么我需要列表是独立的(但仍然一起滚动)的详细信息。请让我知道这是否仍然可以通过一个列表来实现。不知道怎么做。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-11-29
  • 2019-03-20
  • 1970-01-01
  • 1970-01-01
  • 2018-03-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多