MvvmCross MvxListView 和 MvxItemTemplate。如何让 table 正确显示?

MvvmCross MvxListView and MvxItemTemplate. How do I get a table to display correctly?

我正在尝试使用 MvvmCross 创建数据条目 table。这是我拥有的:

ShipmentView.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="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="@style/InputEditText"
        local:MvxBind="Text Shipment.Shipper" />
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="@style/InputEditText"
        local:MvxBind="Text Shipment.OrgAddress" />
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="@style/InputEditText"
        local:MvxBind="Text Shipment.OrgEmail" />
    <Mvx.MvxListView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        local:MvxBind="ItemsSource ShipmentInventory.Items"
        local:MvxItemTemplate="@layout/inventoryitemdetailview" />
</LinearLayout>

ShipmentInventory.Items 是 ShipmentInventoryItem 的 ObservableCollection。我的项目模板如下:

<?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="fill_parent"
    android:layout_height="fill_parent">
  <EditText
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      style="@style/InputEditText"
      local:MvxBind="Text TagColor" />
  <EditText
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      style="@style/InputEditText"
      local:MvxBind="Text TagLot" />
  <EditText
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      style="@style/InputEditText"
      local:MvxBind="Text Articles" />
</LinearLayout>

我的 ViewModel 的代码是:

using Cirrious.MvvmCross.ViewModels;
using MPS_Mobile_Driver.Droid.DataModel;
using MPSDataService;
using System;

namespace MPS_Mobile_Driver.Droid.ViewModels
{
    public class ShipmentViewModel
      : MvxViewModel
    {
        public async void Init(int idno, short idsub)
        {
            Shipment = await MPS_Mobile_Driver.Droid.DataModel.ShipmentDataSource.GetShipment(idno, idsub);
            await MPS_Mobile_Driver.Droid.DataModel.ShipmentDataSource.GetShipmentInventory (Guid.Parse("59361EA3-C688-41FB-AF96-DF50F357272B"));
            ShipmentInventory = ShipmentDataSource.CurrInventory;
        }

        private Shipment _Shipment;
        public Shipment Shipment
        {
            get { return _Shipment; }
            set { _Shipment = value; RaisePropertyChanged(() => Shipment); }
        }
        private ShipmentInventory _ShipmentInventory;
        public ShipmentInventory ShipmentInventory
        {
            get { return _ShipmentInventory; }
            set { _ShipmentInventory = value; RaisePropertyChanged(() => ShipmentInventory); }
        }
    }
}

除了 MvxListView 中的细节被顶起外,这一切都正常。它将第一列的值显示为整行,然后将其他两列的值显示为空白行,然后冲洗并重复约 30 个项目。我的主题模板只是将其设为白色背景和黑色字母。如下以防万一有问题:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <style name="InputEditText" parent="android:style/Widget.EditText">
    <item name="android:textColor">@color/black</item>
    <item name="android:background">@color/white</item>
    <item name="android:textSize">20dp</item>
    <item name="android:textCursorDrawable">@drawable/black_cursor</item>
    <item name="android:layout_margin">5dp</item>
    <item name="android:padding">2dp</item>
  </style>
</resources>

也许我不应该使用线性布局。我确实希望 table 在屏幕上有列。我是 Android 编程的新手,所以我确信我错过了一些微小的细节。任何帮助将不胜感激。

吉姆

这实际上是一个非常容易解决的问题,因为我是 Android 的菜鸟。我所要做的就是在 EditTexts 上设置一个固定的宽度...

<?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="fill_parent"
    android:layout_height="fill_parent">
  <EditText
      android:layout_width="300dp"
      android:layout_height="wrap_content"
      style="@style/InputEditText"
      local:MvxBind="Text TagColor" />
  <EditText
      android:layout_width="300dp"
      android:layout_height="wrap_content"
      style="@style/InputEditText"
      local:MvxBind="Text TagLot" />
  <EditText
      android:layout_width="300dp"
      android:layout_height="wrap_content"
      style="@style/InputEditText"
      local:MvxBind="Text Articles" />
</LinearLayout>

@Stuart 感谢您查看此内容。以后在 post 中使用它之前,我将不得不 google 我的俚语。这就是我认为的意思,但它还有很多其他含义 O.o

干杯, 吉姆