Example #1
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;
  }
Example #2
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;
  }
  @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);
  }
Example #4
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);

    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);
  }
Example #6
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;
  }
Example #7
0
  @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();
  }
 /**
  * Set the color of the tab indicator bar from a color resource.
  *
  * @param resId Resource ID of a color resource to load
  */
 public void setTabIndicatorColorResource(int resId) {
   setTabIndicatorColor(getContext().getResources().getColor(resId));
 }
 public void setTabIndicatorColorResource(int paramInt) {
   setTabIndicatorColor(getContext().getResources().getColor(paramInt));
 }