您的位置:首页 > 其它

baseAdapt getView 重复执行很对遍原因

2015-05-07 18:05 148 查看
<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 的行数。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐