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,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

    评论

报告相同问题?

悬赏问题

  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致