//只含有list的view View menuview = View.inflate(mActivity, R.layout.news_menu_detail, null); mlvNewsDetail = (ListView) menuview.findViewById(R.id.lv_new_detail); //只含有topnew图片的viewpager View headview=View.inflate(mActivity, R.layout.list_header_topnews, null); vpTopNews = (ViewPager) headview.findViewById(R.id.vp_news); //将viewpager添加到list中作为头 mlvNewsDetail.addHeaderView(headview);
Listview隐藏头布局
private void initView() { View refreshView = View.inflate(getContext(), R.layout.refresh_header, null); this.addHeaderView(refreshView); refreshView.measure(0, 0); int height = refreshView.getMeasuredHeight(); refreshView.setPadding(0,- height, 0, 0); }