2016-11-16 72 views
0

嗨MvvmCross/Xamarin离散事件,刷卡刷新布局打破回收项目模板

我已经跑入周围MvxRecyclerView和android.support.v4.widget.SwipeRefreshLayout围绕一个问题。

  • Xamarin版本:7.0.1.3(Xamarin业务)
  • SDK工具版本:25.1.7
  • SDK平台工具版本:24.0.1
  • SDK构建工具在Android上使用会出现此问题版本:23.0.3
  • MvvmCross V4.3.0。

这就是发生了什么事。我有一个绑定到可观察集合的MvxRecyclerView,并且有一个自定义模板。当我们点击列表底部时,我也使用TemplateSelector显示“加载单元格”。 MvxRecyclerList封装在android.support.v4.widget.SwipeRefreshLayout中以实现刷新模式。

当结果加载到列表中时,它应该显示为应该显示,回到列表并返回列表。单元格模板布局看起来应该完全一样。正如你可以看到下面。

enter image description here

然而,当我做一拉,刷新和我在等待最后的数据返回布局是“破”,一切都在那里,但它搞砸了。见下面

enter image description here

如果这是不奇怪的是,你这样做是残破交换每次细胞拉刷新。

enter image description here

有时没有被破坏。最后要补充的是,这些单元格在回收时会修复它们。

我已经缩小了事实,即MvxRecyclerView包装在SwipeRefreshLayout中,没有我可以多次调用reload函数而没有一次单元窃听。

任何帮助或指针,将不胜感激。

UPDATE:ItemTemplate中的Xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:local="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="#fff"> 
<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="100dp"> 
    <Mvx.MvxImageView 
     android:id="@+id/car_item_template_image_view" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:layout_gravity="center_vertical" 
     android:layout_marginLeft="10dp" 
     android:scaleType="centerCrop" 
     android:background="@drawable/image_placeholder" 
     local:MvxBind="ImageUrl MainImageUrl" /> 
    <RelativeLayout 
     android:orientation="vertical" 
     android:background="@color/white" 
     android:layout_width="fill_parent" 
     android:layout_height="80dp" 
     android:layout_marginLeft="10dp" 
     android:layout_gravity="center_vertical"> 
     <TextView 
      android:id="@+id/car_item_template_make_text" 
      android:text="Make" 
      android:layout_width="wrap_content" 
      android:layout_height="25dp" 
      android:textColor="@color/theme_blue" 
      android:fontFamily="sans-serif-light" 
      android:textSize="@dimen/car_item_template_title_text_size" 
      local:MvxBind="Text Make, Converter=EmptyStringCheck" 
      android:ellipsize="end" 
      android:singleLine="true" /> 
     <TextView 
      android:text="Model" 
      android:layout_width="@dimen/car_item_template_model_text_width" 
      android:layout_height="25dp" 
      android:layout_marginLeft="7dp" 
      android:textColor="@color/theme_blue" 
      android:layout_toRightOf="@id/car_item_template_make_text" 
      android:layout_toLeftOf="@+id/car_item_template_price_text" 
      android:fontFamily="sans-serif-light" 
      android:textSize="@dimen/car_item_template_title_text_size" 
      local:MvxBind="Text Model, Converter=EmptyStringCheck" 
      android:ellipsize="end" 
      android:singleLine="true" /> 
     <TextView 
      android:id="@+id/car_item_template_price_text" 
      android:text="Price" 
      android:layout_alignParentRight="true" 
      android:layout_alignTop="@+id/car_item_template_make_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="15dp" 
      android:textColor="@color/theme_blue" 
      android:fontFamily="sans-serif-light" 
      android:textSize="@dimen/car_item_template_title_text_size" 
      local:MvxBind="Text Price, Converter=IntToPrice" /> 
     <TextView 
      android:id="@+id/car_item_template_year_text" 
      android:layout_alignParentLeft="true" 
      android:layout_above="@+id/car_item_template_mileage_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Year" 
      android:textSize="@dimen/car_item_template_detail_text_size" 
      local:MvxBind="Text Year, Converter=EmptyShortCheck, ConverterParameter='No Year'" /> 
     <TextView 
      android:id="@+id/car_item_template_mileage_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/car_item_template_location_text" 
      android:layout_alignParentLeft="true" 
      android:text="Mileage" 
      android:textSize="@dimen/car_item_template_detail_text_size" 
      local:MvxBind="Text Mileage, Converter=IntToMileage, ConverterParameter='No Mileage'" /> 
     <TextView 
      android:id="@+id/car_item_template_location_text" 
      android:text="Location" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentLeft="true" 
      android:textSize="@dimen/car_item_template_detail_text_size" 
      local:MvxBind="Text Location, Converter=EmptyStringCheck, ConverterParameter='No Location'" /> 
    </RelativeLayout> 
</LinearLayout> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="1dp" 
    android:layout_alignParentBottom="true" 
    android:background="@drawable/generic_graydivider" /> 
</RelativeLayout> 
+0

安置自己的项目模板。 – Cheesebaron

+0

@Cheesebaron更新的问题。在增加模板xml –

+0

@Cheesebaron我现在正在做一个解决方法,请参阅下面的答案。我仍然不知道是什么导致它:/ –

回答

0

因此,这是针对该问题的解决方法。正如您在上面的模板中看到的那样,TextViews宽度全部设置为wrap_content。我将其更改为固定值,现在问题不再发生。

不幸的是我仍然不知道是什么引起的名单中包含的SwipeRefreshLayout时这样回应:(但是这会为现在要做的。