标签:
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; }
标签:
原文地址:http://blog.csdn.net/codywangziham01/article/details/43227103