baseAdapt getView 重复执行很对遍原因

来源:互联网 发布:nginx伪静态规则写法 编辑:程序博客网 时间:2024/06/15 22:27
<p> </p><p>        mViewSwitcher = (ViewSwitcher)v.findViewById(R.id.switcher);        mViewSwitcher.setFactory(this);mViewSwitcher.getCurrentView().requestFocus();</p>

 


 

    @Overridepublic View makeView() {    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);    mScrollerViewGroup = (InterceptEventCommonViewGroup) inflater.inflate(R.layout.doov_full_mont_by_week_list_view,null, false);    mScrollerViewGroup.setOnGestureListener(mMonthGestureDetector);    mScrollerViewGroup.setOnScrollerStatusListenner(this);return mScrollerViewGroup;}

 

ViewSwitch 中添加listView,

设定:

android:layout_width="match_parent"

 android:layout_height="match_parent"

镶嵌到 RelativeLayout中 即可解决getView执行多次问题:

doov_full_mont_by_week_list_view.xml

<?xml version="1.0" encoding="UTF-8"?><com.doov.calendar.view.InterceptEventCommonViewGroup xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/month_scroller"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:gravity="center" >    <RelativeLayout         android:layout_width="match_parent"        android:layout_height="match_parent"        >    <ListView        android:id="@+id/month_current_list"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:divider="@null"         android:fadeScrollbars="false"        android:fadingEdge="none"        android:drawSelectorOnTop="true" />    </RelativeLayout></com.doov.calendar.view.InterceptEventCommonViewGroup>


 

这样 baseAdapter 中getView的执行次数应该是 getCount();即 listView 的行数。

 

 

0 0