@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;
  }
Exemple #2
0
  @Override
  public View onCreateView(
      final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    articles = MainActivity.articlesReturned;
    savedInflater = inflater;
    savedContainer = container;

    PagerTabStrip pagerTabStrip = (PagerTabStrip) getActivity().findViewById(R.id.pagerTabStrip);
    pagerTabStrip.setDrawFullUnderline(true);
    pagerTabStrip.setTabIndicatorColor(getResources().getColor(R.color.scarlet));
    // Get the view from fragmenttab2.xml
    View view = inflater.inflate(R.layout.article_display, container, false);

    savedView = view;
    if (MainActivity.selectedFrag == 0) {
      // should call a method to handle News fragment recent 2nd tab

      NewsTabRecent(view, inflater, container);
    } else if (MainActivity.selectedFrag == 1) {
      getActivity().setTitle("Calendar");
      // call method to handle actions when Calendar fragment 1st tab
      DisplayAllEvents(view, inflater, container);

    } else if (MainActivity.selectedFrag == 4) {
      view = inflater.inflate(R.layout.status_matrix_oakley, container, false);
    }

    if (MainActivity.networkStatus == false) {
      // return view = inflater.inflate(R.layout.nointernet_view, container, false);
      // Toast.makeText(getActivity().getApplicationContext(), "No Internet Connection",
      // Toast.LENGTH_SHORT).show();
    }

    return view;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTheme(android.R.style.Theme_Light);
    m_vp = (ViewPager) findViewById(R.id.viewpager);
    pagerTabStrip = (PagerTabStrip) findViewById(R.id.pagertab);
    // 设置下划线的颜色
    pagerTabStrip.setTabIndicatorColor(getResources().getColor(android.R.color.holo_green_dark));
    // 设置背景的颜色
    pagerTabStrip.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_dark));

    pagerTitleStrip = (PagerTitleStrip) findViewById(R.id.pagertab);
    // 设置背景的颜色
    pagerTitleStrip.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_dark));

    mfragment1 = new fragment1();
    mfragment2 = new fragment2();
    mfragment3 = new fragment3();

    fragmentList = new ArrayList<Fragment>();
    fragmentList.add(mfragment1);
    fragmentList.add(mfragment2);
    fragmentList.add(mfragment3);

    titleList.add("第一页 ");
    titleList.add("第二页");
    titleList.add("第三页 ");

    m_vp.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager()));
    m_vp.setOffscreenPageLimit(1);
  }
Exemple #4
0
 private PagerTitleStrip getPagerTitle() {
   PagerTabStrip pagerTabStrip =
       (PagerTabStrip) View.inflate(this, R.layout.pager_tab_title, null);
   android.support.v4.view.ViewPager.LayoutParams lp = new ViewPager.LayoutParams();
   lp.width = LayoutParams.MATCH_PARENT;
   lp.height = LayoutParams.WRAP_CONTENT;
   lp.gravity = Gravity.TOP;
   pagerTabStrip.setLayoutParams(lp);
   return pagerTabStrip;
 }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_pager);
   mViewPager = (ViewPager) findViewById(R.id.viewpager);
   PagerTabStrip pagerTabStrip = (PagerTabStrip) findViewById(R.id.pagerTabStrip);
   pagerTabStrip.setTextSize(
       TypedValue.COMPLEX_UNIT_PX,
       Integer.parseInt(getResources().getString(R.string.size_pager_text)));
   pagerTabStrip.setTextColor(Color.WHITE);
   TitleAdapter titleAdapter = new TitleAdapter(getSupportFragmentManager());
   mViewPager.setAdapter(titleAdapter);
   mViewPager.setCurrentItem(0);
   // titleAdapter.getItem(position);
   mViewPager.setOffscreenPageLimit(4);
 }
  @Override
  public void draw(Canvas canvas) {
    super.draw(canvas);

    final int height = getHeight();
    canvas.drawRect(0, height - shadowSize, getWidth(), height, shadowPaint);
  }
  @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.activity_main);

    viewList = new ArrayList<View>();

    // 通过View对象作为ViewPager的数据源
    View view1 = View.inflate(this, R.layout.view1, null);
    View view2 = View.inflate(this, R.layout.view2, null);
    View view3 = View.inflate(this, R.layout.view3, null);
    View view4 = View.inflate(this, R.layout.view4, null);

    viewList.add(view1);
    viewList.add(view2);
    viewList.add(view3);
    viewList.add(view4);

    // 初始化ViewPager
    viewPager = (ViewPager) findViewById(R.id.pager);

    // 为ViewPager设置标题
    titleList = new ArrayList<String>();
    titleList.add("第一页");
    titleList.add("第二页");
    titleList.add("第三页");
    titleList.add("第四页");

    // 为PagerTabStrip设置一些属性
    tabStrip = (PagerTabStrip) findViewById(R.id.pagerTab);
    tabStrip.setBackgroundColor(Color.BLUE);
    tabStrip.setTextColor(Color.RED);
    tabStrip.setDrawFullUnderline(false);
    tabStrip.setTabIndicatorColor(Color.GREEN);

    // 创建PagerAdapter的适配器
    MyPagerAdapter adapter = new MyPagerAdapter(viewList, titleList);

    // ViewPager加载适配器
    viewPager.setAdapter(adapter);
  }
  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);
  }
Exemple #10
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.wall_sample_layout, container, false);

    mCustomPagerAdapter =
        new CustomPagerAdapter(getFragmentManager(), getActivity().getApplicationContext());

    mViewPager = (ViewPager) view.findViewById(R.id.pager);

    mViewPager.setAdapter(mCustomPagerAdapter);

    //     mViewPager.setCurrentItem(0);
    //    mCustomPagerAdapter.setPrimaryItem(container,0,new notificationFragment());
    PagerTabStrip pagerTabStrip = (PagerTabStrip) view.findViewById(R.id.pager_title_strip);
    pagerTabStrip.setBackgroundColor(getResources().getColor(R.color.fragment_tab));
    pagerTabStrip.setTabIndicatorColor(getResources().getColor(R.color.backtab));
    //    pagerTabStrip.setTextSize(5,16);

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

    setContentView(R.layout.layout_viewpager_pagertabstrip);

    // KHOI TAO DOI TUONG
    mPagerAdapter = new PagerAdapter(getSupportFragmentManager(), this);

    // LOAD VAO VIEWPAGER
    mViewPager = (ViewPager) findViewById(R.id.pagerTabStrip);
    mViewPager.setAdapter(mPagerAdapter);

    mTabStrip = (PagerTabStrip) findViewById(R.id.tabStrip);
    mTabStrip.setDrawFullUnderline(false);
  }
Exemple #12
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    strip.setDrawFullUnderline(false);
    strip.setTabIndicatorColor(Color.DKGRAY);
    strip.setBackgroundColor(Color.GRAY);
    strip.setNonPrimaryAlpha(0.5f);
    strip.setTextSpacing(15);
    strip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);

    // Note: 此处使用ViewPager,只能使用getChildFragmentManager(),否则弹栈将出现问题
    // http://stackoverflow.com/questions/7338823/viewpager-recursive-entry-to-executependingtransactions
    viewPager.setAdapter(new HomePagerAdapter(getChildFragmentManager()));
    viewPager.setOnPageChangeListener(new HomePageChangeListener());
    viewPager.setPageTransformer(false, new HomePageTransformer());
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.dl);
    mViewPager = (ViewPager) findViewById(R.id.vp);
    mTabStrip = (PagerTabStrip) findViewById(R.id.pager_tab_strip);
    mTabStrip.setTabIndicatorColor(getResources().getColor(R.color.indicatorcolor));

    mViewPager.setAdapter(new MainAdapter(getSupportFragmentManager()));

    mDrawerToggle =
        new ActionBarDrawerToggle(
            this,
            mDrawerLayout,
            R.drawable.ic_drawer_am,
            R.string.drawer_open,
            R.string.drawer_open) {

          @Override
          public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
          }

          @Override
          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
          }
        };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
  }
  @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);
          }
        });
  }