将MvxBindableSpinner放在MvxBindableListView中时,为什么gref会过高? [英] Why does the gref go too high when I put a MvxBindableSpinner in a MvxBindableListView?

查看:61
本文介绍了将MvxBindableSpinner放在MvxBindableListView中时,为什么gref会过高?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mvvmcross开发适用于Android的应用程序.

在此应用程序中,我想要一个包含微调框的列表.当我在模拟器上测试应用程序时,它看起来还可以,但是当我滚动时,它很快就会耗尽内存,因为gref超过2000.我知道gref在真实设备上可以更高,但是我仍然认为我一定做错了

BindableList

    <cirrious.mvvmcross.binding.android.views.MvxBindableListView
          android:id="@+id/propertyHolder"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_below="@id/obsBtLayout"
          android:layout_above="@id/photoframe"          
          local:MvxBind="
          {
            'ItemsSource':{'Path':'PPHolders'},
            'ItemClick':{'Path':'PropertyClickedCommand'}
          }"
          local:MvxItemTemplate="@layout/listitem_property"
        />

ListItem_Property.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/AIPApp.UI.Droid"
  android:orientation="horizontal"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/ListItemSelector"           
  android:descendantFocusability="beforeDescendants"
  >

  <cirrious.mvvmcross.binding.android.views.MvxBindableSpinner
    android:layout_gravity="center_horizontal"
    android:layout_width="200dip"
    android:layout_height="wrap_content"    
    local:MvxDropDownItemTemplate="@layout/spinneritem_propdropdown"
    local:MvxItemTemplate="@layout/spinneritem_prop"
    local:MvxBind="
    {
      'ItemsSource':{'Path':'CodeTableValues'},      
      'SelectedItem':{'Path':'ObservedCodeTable'},
      'Visibility':{'Path':'IsCodeTableValue','Converter':'Visibility'}
    }"/>     

</LinearLayout>

这是因为每次滚动时都必须重新构建微调器项吗?因为绑定到的列表在列表中的每个项目中都不同.因此,在一个列表项上,微调框列表的长度可以为6个项目,在另一个列表项上则可以为3个项目,以此类推.

解决方案

我还没有对您所看到的行为进行完整的分析-如果没有完整的代码示例,这很难做到.

但是,尤其要感谢JonPryor在 Xamarin论坛我相信我现在至少对一般情况下的GREF发生了更好的了解-因此我可以回答您的为什么"问题.


绑定列表的一般情况是GREF递增:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆