转: http://www.maxiaoguo.com/shipin/392.html
1、关键字:viewpager 获取 某一个viewpager中的某一个 view
ViewPagerAdapter viewPagerAdapters = (ViewPagerAdapter) viewpager.getAdapter();
LinearLayout linearLayout = (LinearLayout) viewPagerAdapters.instantiateItem(null, currentItem);
2、获取fragment中的listview中的headview
代码如下
LinearLayout ll = (LinearLayout) viewPagerAdapters.instantiateItem(null, currentItem);
if(ll==null){
System.err.println(ll);
return;
}
ListView listview = (ListView) ll.getChildAt(0);
HeaderViewListAdapter adapter2 = (HeaderViewListAdapter) listview.getAdapter();
HorizontalScrollView teachingStratehs = (HorizontalScrollView) adapter2.getView(0, null, listview);
代码如下
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
if (null != rootView) {
ViewGroup parent = (ViewGroup) rootView.getParent();
if (null != parent) {
parent.removeView(rootView);
}
} else {
rootView = inflater.inflate(R.layout.news_fragment, null);
setupView(rootView);// 控件初始化
}
return rootView;
}
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。