@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) { MinicRPCLog.d(TAG, "onCreateView"); } View view = View.inflate(getActivity(), R.layout.fragment_smsbless, null); ButterKnife.inject(this, view); // init fragments mFragments[0] = new FA(); mFragments[1] = new FB(); mFragments[2] = new FC(); mFragments[3] = new FD(); // init mTitle = getActivity().getResources().getStringArray(R.array.sms_bless); if (DEBUG) { MinicRPCLog.d(TAG, "%s, %s, %s, %s", mTitle); } mAdapter = new MyAdapter(getChildFragmentManager()); mPager.setAdapter(mAdapter); mIndicator.setViewPager(mPager); mIndicator.setCurrentItem(0); return view; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_tabs); FragmentPagerAdapter adapter = new GoogleMusicAdapter(getSupportFragmentManager()); ViewPager pager = (ViewPager) findViewById(R.id.pager); pager.setAdapter(adapter); TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator); indicator.setViewPager(pager); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); initLocations(); FragmentPagerAdapter adapter = new ServerFileExplorerAdapter(getSupportFragmentManager()); ViewPager pager = (ViewPager) findViewById(R.id.paper); pager.setAdapter(adapter); TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator); indicator.setViewPager(pager); prepareActionBar(); }
@Override public void spotsLoaded(boolean fromCache, List<SpotData> _spots) { // this is called when the spots are loaded. // it is called twice,first with values from the local cache and later with new updated values // from internet if (fromCache && _spots == null) { // since this is from cache, show a loading screen. Later this function is called again but // with non-cached values showLoading(); return; } if (!fromCache && _spots == null) { // ok, there are really no spots showNoData(); return; } if (SpotStorage.sameSpots(_spots, mSpots)) { return; // no change } mSpots = _spots; if (mTabPageIndicator != null && mFragmentAdapter != null) { mFragmentAdapter.setSpots(_spots); mTabPageIndicator.notifyDataSetChanged(); } showSpots(); }
private void initView() { viewPager = (ViewPager) findViewById(R.id.id_viewpager); tabPageIndicator = (TabPageIndicator) findViewById(R.id.id_indicator); mAdapter = new TabAdapter(getSupportFragmentManager()); viewPager.setAdapter(mAdapter); tabPageIndicator.setViewPager(viewPager, 0); }
@Override public View initViews() { View view = View.inflate(mActivity, R.layout.news_menu_detail, null); mViewPager = (ViewPager) view.findViewById(R.id.vp_menu_detail); mIndicator = (TabPageIndicator) view.findViewById(R.id.indicator); ib = (ImageButton) view.findViewById(R.id.btn_next); mIndicator.setOnPageChangeListener(this); return view; }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void initialisePaging(View view) { datePickers = new Vector<>(); FrameLayout fl1 = new FrameLayout(getActivity()); FrameLayout fl2 = new FrameLayout(getActivity()); startDatePicker = new DatePicker(getActivity()); startDatePicker.setLayoutParams( new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER)); endDatePicker = new DatePicker(getActivity()); endDatePicker.setLayoutParams( new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER)); // not entirely necessary since this feature will never be supported // below Honeycomb if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { startDatePicker.setCalendarViewShown(false); endDatePicker.setCalendarViewShown(false); } fl1.addView(startDatePicker); fl1.setTag("Start Date"); fl2.addView(endDatePicker); fl2.setTag("End Date"); datePickers.add(fl1); datePickers.add(fl2); ViewPagerAdapter adapter = new ViewPagerAdapter(datePickers); WrappedViewPager pager = (WrappedViewPager) view.findViewById(R.id.wrappedviewpager); pager.setPageMargin(2); pager.setAdapter(adapter); TabPageIndicator tabIndicator = (TabPageIndicator) view.findViewById(R.id.titles); tabIndicator.setViewPager(pager); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void initialisePaging(View view) { datePickers = new Vector<View>(); FrameLayout fl1 = new FrameLayout(getSherlockActivity()); FrameLayout fl2 = new FrameLayout(getSherlockActivity()); startDatePicker = new DatePicker(getSherlockActivity()); startDatePicker.setLayoutParams( new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER)); endDatePicker = new DatePicker(getSherlockActivity()); endDatePicker.setLayoutParams( new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER)); // this is always true for now, but not so when I get 2.x implemented if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { startDatePicker.setCalendarViewShown(false); endDatePicker.setCalendarViewShown(false); } fl1.addView(startDatePicker); fl1.setTag("Start Date"); fl2.addView(endDatePicker); fl2.setTag("End Date"); datePickers.add(fl1); datePickers.add(fl2); ViewPagerAdapter adapter = new ViewPagerAdapter(datePickers); WrappedViewPager pager = (WrappedViewPager) view.findViewById(R.id.wrappedviewpager); pager.setPageMargin(2); pager.setAdapter(adapter); TabPageIndicator tabIndicator = (TabPageIndicator) view.findViewById(R.id.titles); tabIndicator.setViewPager(pager); }
@Override public void initData() { mPagerList = new ArrayList<TabDetailPager>(); // 初始化页签数据 for (int i = 0; i < mNewsTabData.size(); i++) { TabDetailPager pager = new TabDetailPager(mActivity, mNewsTabData.get(i)); mPagerList.add(pager); } mViewPager.setAdapter(new MenuDetailAdapter()); mIndicator.setViewPager(mViewPager); // 将viewpager和mIndicator关联起来,必须在viewpager设置完adapter后才能调用 // 跳转下一个页面 ib.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { int currentItem = mViewPager.getCurrentItem(); mViewPager.setCurrentItem(++currentItem); } }); }
protected void showSpots() { // only load this when not initialized before if (!mInitialized) { mInitialized = true; setContentView(R.layout.activity_details); mFragmentAdapter = new WindFragmentAdapter(getSupportFragmentManager(), mSpots); mIndicator = (PageIndicator) findViewById(R.id.indicator); mPager = (WindViewPager) findViewById(R.id.pager); mPager.setAdapter(mFragmentAdapter); mTabPageIndicator = (TabPageIndicator) findViewById(R.id.indicator); mTabPageIndicator.setViewPager(mPager); // get the mAppWidgetID and the spotID, this is only available when called from a widget mAppWidgetID = -1; if (getIntent() != null && getIntent().getExtras() != null) { mAppWidgetID = getIntent().getExtras().getInt(Const.EXTRA_INTENTINFO_WIDGETID, -1); mInitialSpotID = getIntent().getExtras().getInt(Const.EXTRA_INTENTINFO_SPOTID, -1); } // when mInitialSpotID is still -1, then set the mInitialSpotID to the favoriteSpotID which is // set on the properties if (mInitialSpotID == -1) { mInitialSpotID = LocalStorage.getFavoriteSpotID(this); } } // when we have a saved tab, open this tab again if (mSavedOpenTab != -1) { mPager.setCurrentItem(mSavedOpenTab); } else { // if we did not have a saved spot, then open the tab that belongs to the mInitialSpotID for (int i = 0; i < mSpots.size(); i++) { if (mSpots.get(i).getSiteID() == mInitialSpotID) { mPager.setCurrentItem(i); } } } }