<p> </p><p> mViewSwitcher = (ViewSwitcher)v.findViewById(R.id.switcher);
mViewSwitcher.setFactory(this);
mViewSwitcher.getCurrentView().requestFocus();
</p>
@Override
public 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 的行数。