Example #1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // initialize the inflater
    mInflater = inflater;

    View rootView = mInflater.inflate(R.layout.app_ops_summary, container, false);
    mContentContainer = container;
    mRootView = rootView;

    mPageNames = getResources().getTextArray(R.array.app_ops_categories);

    mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
    MyPagerAdapter adapter = new MyPagerAdapter(getChildFragmentManager());
    mViewPager.setAdapter(adapter);
    mViewPager.setOnPageChangeListener(adapter);
    PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
      tabs.setTabIndicatorColorResource(android.R.color.holo_blue_light);
    } else {
      final TypedValue val = new TypedValue();
      getActivity().getTheme().resolveAttribute(android.R.attr.colorAccent, val, true);
      tabs.setTabIndicatorColor(val.data);
    }

    // We have to do this now because PreferenceFrameLayout looks at it
    // only when the view is added.
    if (container != null
        && "android.preference.PreferenceFrameLayout".equals(container.getClass().getName())) {
      new ObjectWrapper(rootView.getLayoutParams()).set("removeBorders", true);
    }

    return rootView;
  }
Example #2
0
  private void initPagers() {
    FragmentListPagerAdapter pagerAdapter =
        new FragmentListPagerAdapter(
            getSupportFragmentManager(),
            PAGER_TITLES,
            new VmsFragment_(),
            new HostsFragment_(),
            new EventsFragment_());

    viewPager.setAdapter(pagerAdapter);
    pagerTabStrip.setTabIndicatorColorResource(R.color.material_deep_teal_200);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    container.setLayoutDirection(container.getResources().getConfiguration().getLayoutDirection());
    // initialize the inflater
    mInflater = inflater;

    View rootView = mInflater.inflate(R.layout.manage_applications_content, container, false);
    mContentContainer = container;
    mRootView = rootView;

    mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
    MyPagerAdapter adapter = new MyPagerAdapter();
    mViewPager.setAdapter(adapter);
    mViewPager.setOnPageChangeListener(adapter);
    PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);
    tabs.setTabIndicatorColorResource(android.R.color.holo_blue_light);

    // We have to do this now because PreferenceFrameLayout looks at it
    // only when the view is added.
    if (container instanceof PreferenceFrameLayout) {
      ((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
    }

    if (savedInstanceState != null && savedInstanceState.getBoolean(EXTRA_RESET_DIALOG)) {
      buildResetDialog();
    }

    if (savedInstanceState == null) {
      // Reverse the tab list once if the language is RTL.
      if (container.isLayoutRtl()) {
        Collections.reverse(mTabs);
      }
      // First time init: make sure view pager is showing the correct tab.
      for (int i = 0; i < mTabs.size(); i++) {
        TabInfo tab = mTabs.get(i);
        if (tab.mListType == mDefaultListType) {
          mViewPager.setCurrentItem(i);
          break;
        }
      }
    }

    return rootView;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.reader_activity_subs);
    restoreState(savedInstanceState);

    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mViewPager.setAdapter(getPageAdapter());

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onBackPressed();
          }
        });
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    PagerTabStrip tabStrip = (PagerTabStrip) findViewById(R.id.pager_tabs);
    tabStrip.setTabIndicatorColorResource(R.color.tab_indicator);
    tabStrip.setTextColor(getResources().getColor(R.color.tab_text_selected));

    mEditAdd = (EditText) findViewById(R.id.edit_add);
    mEditAdd.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              addCurrentEntry();
            }
            return false;
          }
        });

    mBtnAdd = (ImageButton) findViewById(R.id.btn_add);
    mBtnAdd.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            addCurrentEntry();
          }
        });

    if (savedInstanceState == null) {
      // return to the page the user was on the last time they viewed this activity
      restorePreviousPage();
    }

    // remember which page the user last viewed - note this listener must be assigned
    // after we've already called restorePreviousPage()
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            String pageTitle = (String) getPageAdapter().getPageTitle(position);
            AppPrefs.setReaderSubsPageTitle(pageTitle);
          }
        });
  }