a13252912215 2015-11-27 09:31 采纳率: 0%
浏览 1518
已结题

android listview反复调用getview()

哪位大神帮忙看看,只要一滑动listview就会调用调用getView,我的listview和父view都是fill_parent啊 求帮忙!

<?xml version="1.0" encoding="utf-8"?>
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:id="@+id/shop_cat_relativeLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/grey"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/total_textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:text="共  件商品"
        android:textColor="@color/black"
        android:textSize="20dip" />

    <com.handmark.pulltorefresh.library.PullToRefreshListView
        xmlns:ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/shop_cat_listView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/white"
        android:dividerHeight="1dp"
        android:fadingEdge="none"
        android:fastScrollEnabled="false"
        android:footerDividersEnabled="false"
        android:headerDividersEnabled="false"
        android:smoothScrollbar="true"
        android:layout_marginBottom="50dp"
        android:cacheColorHint="#00000000"
        android:listSelector="#00000000"
         />

</LinearLayout>

<RelativeLayout
    android:id="@+id/shop_cat_bottom"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/darkgrey"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/shop_cat_totalprice"
            android:layout_width="200dp"
            android:layout_height="fill_parent"
            android:layout_margin="15dp"
            android:text="合计:¥0.00"
            android:textColor="@color/white"
            android:textSize="15dp" />

        <TextView
            android:id="@+id/go_pay"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@color/red"
            android:gravity="center"
            android:text="去结算"
            android:textColor="@color/white"
            android:textSize="15dp" />
    </LinearLayout>
</RelativeLayout>

  • 写回答

3条回答 默认 最新

  • Robot-C 2015-11-27 09:40
    关注

    最近做项目发现一个界面当有ListView是,getView和getCount中的log被疯狂调用。一个5个Item的ListView,getView竟然会被反复调用7组。尤其是当ItemView中需要加载图片时,很容易造成GC过多,很容易出现ANR。

    原因就在于measure过程,ListView一般都会有好多个Item,而且也会同时显示若干组Item,这些Item的父元素都是这个Li......
    答案就在这里:Android ListView反复调用getView和getCount
    ----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?