当前位置: 主页 > 开源代码 >

listview下拉刷新仿最新版美团外卖

分享

介绍:

/** * 初始化view * * @param context */ private void init(Context context) { setOverScrollMode(View.OVER_SCROLL_NEVER); setOnScrollListener(this); headerView = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.listview_head_view, null, false); footerView = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.listview_foot_view, null, false); tv_load = (TextView) footerView.findViewById(R.id.tv_load); bg_view= (RefreshBgView) headerView.findViewById(R.id.bg_view); bg_view.setBackgroundResource(R.drawable.loading_bg1); bg_viewAnimation = (AnimationDrawable) bg_view.getBackground(); bg_viewAnimation.start(); refreshAnimView = (RefreshAnimView) headerView.findViewById(R.id.first_step_view); refreshLoadingView= (RefreshLoadingView) headerView.findViewById(R.id.second_step_view); refreshLoadingView.setBackgroundResource(R.drawable.anim_refresh); loadAnimation = (AnimationDrawable) refreshLoadingView.getBackground(); measureView(headerView); measureView(footerView); addHeaderView(headerView); addFooterView(footerView); headerViewHeight = headerView.getMeasuredHeight(); footerViewHeight = footerView.getMeasuredHeight(); headerView.setPadding(0, -headerViewHeight, 0, 0); footerView.setPadding(0, 0, 0, -footerViewHeight); refreshstate = REFRESH_DONE; loadstate = LOAD_DONE; isRefreshable = true; isLoadable = true; }

运行效果: