// 创建视图格式 @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.activity_viewpager, null); activity = (BaseActivity) getActivity(); ViewUtils.inject(this, view); if (from != null && from.equals(Constants.EXTRA_FROM_COMMENT_EDIT) || from.equals(Constants.EXTRA_FROM_FRAGMENT_MESSAGE)) { activity.initActionBar(R.drawable.icon_back, 0, getString(R.string.title_member), false); activity.setOnClickLeftListener( new View.OnClickListener() { @Override public void onClick(View v) { activity.detachFragment(MemberContainerFrg.this); if (onActionBarUpdateListener != null) { onActionBarUpdateListener.shouldUpdateActionBar(); } } }); } else if (from.equals(Constants.EXTRA_FROM_HOME)) { activity.initActionBar( R.drawable.icon_navigation, 0, getString(R.string.title_member), false); } setSearchView(); sideBar.setVisibility(View.VISIBLE); sideBar.setTextView(alphabeticHint); tabStrip.setUnderlineHeight(1); tabStrip.setDividerColorResource(R.color.slide_filler); tabStrip.setDividerPadding(DensityUtil.dip2px(activity, 4)); return view; }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); pagerAdapter = new PagerAdapter(getChildFragmentManager()); pager.setAdapter(pagerAdapter); tabStrip.setViewPager(pager); tabStrip.setOnPageChangeListener(new OnPageScrollListener()); pullRefreshListViewMap = new HashMap<Integer, PullRefreshListView>(3); memberAdapterMap = new HashMap<Integer, MemberAdapter>(3); // 设置右侧触摸监听 sideBar.setOnTouchingLetterChangedListener( new SideBar.OnTouchingLetterChangedListener() { @Override public void onTouchingLetterChanged(String s) { // 该字母首次出现的位置 int position = memberAdapterMap.get(pager.getCurrentItem()).getPositionForSection(s.charAt(0)); if (position != -1) { pullRefreshListViewMap.get(pager.getCurrentItem()).setSelection(position); } } }); menuDrawer = activity.getMenuDrawer(); if (menuDrawer != null) { menuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN); } }