Ejemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_exam217);

    // 테이블레이아웃
    mTabLayout = (TabLayout) findViewById(R.id.tablayout);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);

    // 탭설정하기
    mTabLayout.addTab(mTabLayout.newTab().setText("플레이어"));
    mTabLayout.addTab(mTabLayout.newTab().setText("아티스트"));
    mTabLayout.addTab(mTabLayout.newTab().setText("노래"));

    // view에 들어갈 데이터를 준비해야 한다.
    mData = new ArrayList<>();
    mData.add(new ArtistFragment());

    // Adapter 준비
    mAdapter = new MyPagerAdater(getSupportFragmentManager(), mData);

    // view에 어뎁터 붙이기
    mViewPager.setAdapter(mAdapter);

    // 탭레이아웃 붙히기 (뷰페이저와 탭레이아웃 연결 하기)
    mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.people_org_pager, container, false);

    TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab_layout_org);
    tabLayout.addTab(tabLayout.newTab().setText("FOLLOWING"));
    tabLayout.addTab(tabLayout.newTab().setText("FOLOWERS"));
    tabLayout.addTab(tabLayout.newTab().setText("ORGANIZATIONS"));

    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    final ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager_org);
    final PagerOrgAdapter adapter =
        new PagerOrgAdapter(getActivity().getSupportFragmentManager(), tabLayout.getTabCount());
    viewPager.setAdapter(adapter);
    viewPager.setOffscreenPageLimit(2);

    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            viewPager.setCurrentItem(tab.getPosition());
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });
    return view;
  }
Ejemplo n.º 3
0
 private void initTabs() {
   tabLayout = (TabLayout) findViewById(R.id.tab_layout);
   tabLayout.addTab(tabLayout.newTab().setText(titles[0]));
   tabLayout.addTab(tabLayout.newTab().setText(titles[1]));
   tabLayout.addTab(tabLayout.newTab().setText(titles[2]));
   tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
 }
Ejemplo n.º 4
0
  private void initTabs(View inflatedView) {

    TabLayout tabLayout = (TabLayout) inflatedView.findViewById(R.id.tab_layout);
    tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
    tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));
    tabLayout.addTab(tabLayout.newTab().setText("Tab 3"));
    tabLayout.setOnTabSelectedListener(ContainerFragment3.this);
  }
Ejemplo n.º 5
0
  private void initFragment() {
    // tabLayout.removeAllTabs();

    pagerAdapter.addFragment(new AllTopListFragment());
    TabLayout.Tab tab1 = tabLayout.newTab();
    tab1.setCustomView(R.layout.tab_item);
    // tabLayout.addTab(tab1);

    pagerAdapter.addFragment(new PersonalTopListFragment());
    TabLayout.Tab tab2 = tabLayout.newTab();
    tab2.setCustomView(R.layout.tab_item);
    // tabLayout.addTab(tab2);
  }
Ejemplo n.º 6
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_cards, container, false);

    final FloatingActionButton btn = (FloatingActionButton) rootView.findViewById(R.id.btn);
    btn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(getActivity(), CoordinatorLayoutActivity.class);

            Bundle bundle = new Bundle();
            // bundle.putString("name", "杭州公交卡");
            // bundle.putString("number", "1111111111111111111");
            // intent.putExtra("data", bundle);
            intent.putExtra("cardInfo", new CardInfo("杭州公交卡", "1111111111111111111"));

            // startActivity(intent);
            startActivityForResult(intent, 0);
          }
        });
    ViewPager viewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
    //        TextView txtCard=(TextView) rootView.findViewById(R.id.txtCard);
    //        txtCard.setText(mTitle);

    TabLayout tabs = (TabLayout) rootView.findViewById(R.id.tablayout);
    tabs.addTab(tabs.newTab().setText("Tab1"));
    tabs.addTab(tabs.newTab().setText("Tab2"));
    tabs.addTab(tabs.newTab().setText("Tab3"));
    tabs.addTab(tabs.newTab().setText("Tab4"));
    tabs.addTab(tabs.newTab().setText("Tab5"));
    tabs.addTab(tabs.newTab().setText("Tab6"));
    List<String> titles = new ArrayList<>();
    List<Fragment> fragments = new ArrayList<>();
    for (int i = 0; i < 6; i++) {
      String title = "Tab" + (i + 1);
      tabs.addTab(tabs.newTab().setText(title));
      titles.add(title);
      Fragment fragment = CardsFragment.newInstance(title, title);
      fragments.add(fragment);
    }

    cardFragmentAdapter mAdapter =
        new cardFragmentAdapter(getActivity().getSupportFragmentManager(), titles, fragments);
    viewPager.setAdapter(mAdapter);
    tabs.setupWithViewPager(viewPager);
    tabs.setTabsFromPagerAdapter(mAdapter);

    return rootView;
  }
Ejemplo n.º 7
0
  private void setUI() {

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    if (toolbar != null) {
      toolbar.setTitleTextColor(getResources().getColor(R.color.white));
    }

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.addTab(tabLayout.newTab().setText(R.string.current_task)); // создание вкладок
    tabLayout.addTab(tabLayout.newTab().setText(R.string.done_task)); // создание вкладок

    final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    TabAdapter tabAdapter = new TabAdapter(fragmentManager, 2); // 2 - кол-во вкладок

    viewPager.setAdapter(tabAdapter);
    viewPager.addOnPageChangeListener(
        new TabLayout.TabLayoutOnPageChangeListener(
            tabLayout)); // слушатель на смены события вкладок

    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            viewPager.setCurrentItem(
                tab.getPosition()); // передаем необходимый для отображения фрагмент
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override // выбран ранее выбранный таб
          public void onTabReselected(TabLayout.Tab tab) {}
        });
  }
Ejemplo n.º 8
0
  private void updateTabs() {
    if (tabTitles != null) {

      for (DiscoverTab tabTitle : tabTitles) {

        TabLayout.Tab tab = tabBar.newTab();

        tab.setText(tabTitle.getTitle());

        tabBar.addTab(tab);

        // 根据内容类型,来设置指定的Fragment
        String type = tabTitle.getContentType();

        if ("recommend".equals(type)) {
          subFragments.add(new DiscoverRecommendFragment());
        } else if ("category".equals(type)) {
          subFragments.add(new DiscoverCategoryFragment());
        } else if ("live".equals(type)) {
          subFragments.add(new DiscoverLiveFragment());
        } else if ("ranking".equals(type)) {
          subFragments.add(new DiscoverRankingFragment());
        } else if ("anchor".equals(type)) {
          subFragments.add(new DiscoverAnchorFragment());
        }
      }

      CommonFragmentPagerAdapter adapter =
          new CommonFragmentPagerAdapter(getChildFragmentManager(), subFragments);
      pager.setAdapter(adapter);
    }
  }
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  private void initData() {

    ArrayList<String> tabList = new ArrayList<>();
    tabList.add("Tab1");
    tabList.add("Tab2");
    tabList.add("Tab3");

    mTabLayout.setTabMode(TabLayout.MODE_FIXED);

    mTabLayout.addTab(mTabLayout.newTab().setText(tabList.get(0)));
    mTabLayout.addTab(mTabLayout.newTab().setText(tabList.get(1)));
    mTabLayout.addTab(mTabLayout.newTab().setText(tabList.get(2)));

    ArrayList<Fragment> viewList = new ArrayList<>();

    for (int i = 0; i < tabList.size(); i++) {
      Fragment f1 = new TabFragment();
      Bundle bundle = new Bundle();
      bundle.putString("content", "http://blog.csdn.net/feiduclear_up \n CSDN 废墟的树");
      f1.setArguments(bundle);
      viewList.add(f1);
    }

    TabFragmentAdapter fragmentAdapter =
        new TabFragmentAdapter(getFragmentManager(), viewList, tabList);
    viewPager.setAdapter(fragmentAdapter); // 给ViewPager设置适配器
    mTabLayout.setupWithViewPager(viewPager); // 将TabLayout和ViewPager关联起来。
    mTabLayout.setTabsFromPagerAdapter(fragmentAdapter); // 给Tabs设置适配器

    mToolbar.setLogo(R.mipmap.ic_launcher);
    mToolbar.setLogoDescription("齐鲁壹点");

    mToolbar.setNavigationIcon(R.mipmap.small_logo);
    mToolbar.setNavigationContentDescription("测试");
    mToolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Toast.makeText(CustomCoordinatorActivity.this, "HHHHHH", Toast.LENGTH_SHORT).show();
          }
        });
  }
  private void initTabBar() {
    Bundle arguments = new Bundle();
    arguments.putString("username", currentUsername);

    accountFragment = new AccountFragment();
    accountFragment.setArguments(arguments);
    mainWhiskeyListFragment = new MainWhiskeyListFragment();
    mainWhiskeyListFragment.setArguments(arguments);
    userFavoritesFragment = new UserFavoritesFragment();
    userFavoritesFragment.setArguments(arguments);

    TabLayout.Tab accountTab = mainTabBar.newTab();
    TabLayout.Tab mainWhiskeyListTab = mainTabBar.newTab();
    TabLayout.Tab favoritesTab = mainTabBar.newTab();

    mainTabBar.addTab(accountTab);
    mainTabBar.addTab(mainWhiskeyListTab);
    mainTabBar.addTab(favoritesTab);
  }
Ejemplo n.º 11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.my_test);
    Intent i = getIntent();

    doctor = (Doctor) i.getSerializableExtra("doc_details");

    TextView name = (TextView) findViewById(R.id.detail_name);
    name.setText(doctor.getDoctor_name());
    TextView category = (TextView) findViewById(R.id.detail_field);
    category.setText(doctor.getCaregory());

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.addTab(tabLayout.newTab().setText("Details"));
    tabLayout.addTab(tabLayout.newTab().setText("Chambers"));
    tabLayout.addTab(tabLayout.newTab().setText("Comment"));

    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

    final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    final ViewPagerTabFragmentAdapter adapter =
        new ViewPagerTabFragmentAdapter(
            doctor, getSupportFragmentManager(), tabLayout.getTabCount());
    viewPager.setAdapter(adapter);

    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));

    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            viewPager.setCurrentItem(tab.getPosition());
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });
  }
  private void initViews() {
    // INITIALIZE TOOLBAR
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    // INITIALIZE DRAWER
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    // set a custom shadow that overlay the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view  with items and click listener
    mActionBarDrawerToggle =
        new ActionBarDrawerToggle(
            this, mDrawerLayout, mToolbar, R.string.app_name, R.string.app_name);
    mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);

    // INITIALIZE RECYCLER VIEW
    mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    // If the size of views will not change as the data changes.
    mRecyclerView.setHasFixedSize(true);
    // setting the layout manager
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
    // setting the adapter
    mAdapter = new MyRecyclerAdapter(this);
    mRecyclerView.setAdapter(mAdapter);

    // INITIALIZE TAB LAYOUT
    mTabLayout = (TabLayout) findViewById(R.id.tabLayout);
    mTabLayout.addTab(mTabLayout.newTab().setText("News Feed"));
    mTabLayout.addTab(mTabLayout.newTab().setText("Favorites"));
    mTabLayout.addTab(mTabLayout.newTab().setText("Your Posts"));

    // INITIALIZE FLOATING ACTION BUTTON
    mFloatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
    mFloatingActionButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(new Intent(MainActivity2.this, MyItemInputFieldsActivity.class));
          }
        });
  }
  // Change the page
  // Update Webview, Toolbar, Refresh button...
  void changePage(Pages newPage) {
    actual = newPage;

    // Handle tabs
    tabs.removeAllTabs();
    if (newPage.tabs != null && newPage.tabs.contains("||")) {
      showTabs();
      for (String s : newPage.tabs.split("\\|\\|")) {
        tabs.addTab(tabs.newTab().setText(s));
      }
      if (newPage.url != null) {
        newPage.actualURL = newPage.url.split("\\|\\|")[0];
      }
      if (newPage.localPage != null) {
        newPage.actualAlternativeURL = newPage.localPage.split("\\|\\|")[0];
      }

      // There are no tabs...
    } else {
      hideTabs();
      newPage.actualURL = newPage.url;
      newPage.actualAlternativeURL = newPage.localPage;
    }

    // Enable JS for the webview
    webView.getSettings().setJavaScriptEnabled(true);

    // Load URL to the webview...
    if (newPage.url != null) {
      webView.loadUrl(newPage.actualURL);
    } else {
      if (newPage.localPage != null) // ...Or use local page
      webView.loadUrl("file:///android_asset/" + newPage.actualAlternativeURL);
    }

    // Update Toolbar and Statusbar
    toolbar.setBackgroundColor(newPage.actionBarColor.value);
    drawerLayout.setBackgroundColor(newPage.actionBarColor.value);
    drawerLayout.closeDrawers();
    toolbar.setTitle(newPage.title);

    // Show refresh button
    if (refreshButton != null) {
      if (newPage.refreshButton) {
        refreshButton.setVisible(true);
      } else {
        refreshButton.setVisible(false);
      }
    }

    actual = newPage;
  }
  @Override
  public void initView(View view) {
    super.initView(view);

    setupViewPager(mVpTitle);
    mTbContent.addTab(mTbContent.newTab().setText("图文详情"));
    mTbContent.addTab(mTbContent.newTab().setText("商品参数"));
    mTbContent.addTab(mTbContent.newTab().setText("热卖推荐"));
    mTbContent.setupWithViewPager(mVpTitle);

    mCbGoodsDetail.getViewPager().setPageTransformer(true, new FlipHorizontalTransformer());
    mCbGoodsDetail.setPages(
        new CBViewHolderCreator<NetworkImageHolderView>() {
          @Override
          public NetworkImageHolderView createHolder() {
            return new NetworkImageHolderView();
          }
        },
        Arrays.asList(images)) // 设置两个点图片作为翻页指示器,不设置则没有指示器,可以根据自己需求自行配合自己的指示器,不需要圆点指示器可用不设
    //                .setOnPageChangeListener(this)//监听翻页事件
    //                            .setOnItemClickListener(this);
    ;
  }
Ejemplo n.º 15
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    tabLayout = (TabLayout) findViewById(R.id.tabLayout);
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new PagerAdapter(getFragmentManager()));
    tabLayout.addTab(tabLayout.newTab().setText(R.string.front));
    tabLayout.addTab(tabLayout.newTab().setText(R.string.back));
    if (savedInstanceState == null) {
      CountryIntentService.start(this, countryReceiver);
    }
    pager.setPageTransformer(
        true,
        new ViewPager.PageTransformer() {
          @Override
          public void transformPage(View page, float position) {
            page.setRotationY(180 * position);
          }
        });
    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            pager.setCurrentItem(tab.getPosition(), false);
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });
    pager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {
            tabLayout.getTabAt(position).select();
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });
  }
Ejemplo n.º 16
0
  private void init() {
    inflate(getContext(), R.layout.view_organization, this);
    mTvTitle = (TextView) findViewById(R.id.tv_title_VO);
    mTvRegion = (TextView) findViewById(R.id.tv_region_VO);
    mTvCity = (TextView) findViewById(R.id.tv_city_VO);
    mTvPhone = (TextView) findViewById(R.id.tv_phone_VO);
    mTvAddress = (TextView) findViewById(R.id.tv_address_VO);

    mTabLayout = (TabLayout) findViewById(R.id.tabLayout);
    mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    for (int i = 0; i < 4; i++) {
      mTabLayout.addTab(mTabLayout.newTab().setIcon(mImageResId[i]));
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_dashboard);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    setSupportActionBar(toolbar);

    getSupportActionBar().setDisplayHomeAsUpEnabled(false);

    getSupportActionBar().setDisplayShowTitleEnabled(false);

    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

    getSupportActionBar().setCustomView(R.layout.action_bar);

    TextView tab = (TextView) findViewById(R.id.mytext);

    tab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            settings = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);

            editor = settings.edit();

            editor.putString("Username", "");

            editor.commit();

            Intent intent = new Intent(getBaseContext(), Dashboard.class);

            startActivity(intent);
          }
        });

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    nestedScroll = (NestedScrollView) findViewById(R.id.mainscroll);

    nestedScroll.setFillViewport(true);

    tabLayout = (TabLayout) findViewById(R.id.tabs);

    tabLayout.setSelectedTabIndicatorColor(Color.parseColor("#007f12"));

    tabLayout.addTab(tabLayout.newTab().setText("DETAILS"), 0, true);

    tabLayout.addTab(tabLayout.newTab().setText("ADDRESS"), 1, false);

    mframeLayout = (FrameLayout) findViewById(R.id.content_frame);

    getSupportFragmentManager()
        .beginTransaction()
        .add(R.id.content_frame, new Sign_up_details())
        .commit();

    tabLayout.setOnTabSelectedListener(new OnTabSelectedListener());

    bList = (ListView) findViewById(R.id.welcomelist);

    bList.setAdapter(
        new CustomAdapter(this, getResources().getStringArray(R.array.home_menu_array)));

    setListViewHeightBasedOnChildren(bList);

    bList.setOnTouchListener(
        new View.OnTouchListener() {
          // Setting on Touch Listener for handling the touch inside ScrollView
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // Disallow the touch request for parent scroll on touch of child view
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
          }
        });

    bList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            if (position == 0) {

              Intent intent = new Intent(getBaseContext(), MoneyTransferCalculator.class);

              startActivity(intent);

            } else if (position == 1) {

              settings = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);

              editor = settings.edit();

              String asd = settings.getString("Username", "");

              if (asd.length() == 0) {

                Intent intent = new Intent(getBaseContext(), Account.class);

                startActivity(intent);

              } else {

                Intent intent = new Intent(getBaseContext(), Dashboard_Fragment.class);

                startActivity(intent);
              }
              Intent intent = new Intent(getBaseContext(), Account.class);

              startActivity(intent);

            } else if (position == 2) {

              Intent viewIntent =
                  new Intent("android.intent.action.VIEW", Uri.parse("http://www.jmtrax.net/"));
              startActivity(viewIntent);

            } else if (position == 3) {

              Intent viewintent =
                  new Intent(
                      "android.intent.action.VIEW",
                      Uri.parse("http://www.jmtrax.com/money-laundering-statement/"));
              startActivity(viewintent);

            } else if (position == 4) {

              Intent intent = new Intent(getBaseContext(), Help.class);

              startActivity(intent);
            }
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_header_scrolling);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // set the toolbar min height
    //        int toolbar_height = PlatformUtils.getToolbarHeight(this) * 2;
    //        CollapsingToolbarLayout.LayoutParams params = (CollapsingToolbarLayout.LayoutParams)
    // toolbar.getLayoutParams();
    //        params.height = toolbar_hight;
    //        toolbar.setLayoutParams(params);

    appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
    appBarLayout.addOnOffsetChangedListener(this);

    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);

    List<String> titles = new ArrayList<>();
    titles.add(" One ");
    titles.add(" Two ");
    titles.add(" Three ");

    mTabLayout.addTab(mTabLayout.newTab().setText(titles.get(0)));
    mTabLayout.addTab(mTabLayout.newTab().setText(titles.get(1)));
    mTabLayout.addTab(mTabLayout.newTab().setText(titles.get(2)));

    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mViewPager.setOffscreenPageLimit(3);

    List<Fragment> fragments = new ArrayList<>();
    mLinearRecyclerFragment = new LinearRecyclerFragment();
    fragments.add(mLinearRecyclerFragment);
    fragments.add(new NestedScrollFragment());
    mGridRecyclerFragment = new GridRecyclerFragment();
    fragments.add(mGridRecyclerFragment);

    mAdapter = new MainTabAdapter(getSupportFragmentManager(), fragments, titles);
    mViewPager.setAdapter(mAdapter);
    mTabLayout.setupWithViewPager(mViewPager);
    mTabLayout.setTabsFromPagerAdapter(mAdapter);

    mHeadViewPager = (ViewPager) findViewById(R.id.header_viewpager);
    mHeadViewAdapter = new HeadViewAdapter(this, null);
    ArrayList<String> headList = new ArrayList<String>();
    headList.add("1111");
    headList.add("1111");
    mHeadViewAdapter.setmLists(headList);
    mHeadViewPager.setAdapter(mHeadViewAdapter);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show();
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post__new__demand);
    this.toolbaractionbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    this.tablayout = (TabLayout) findViewById(R.id.tab_layout);
    tablayout.addTab(tablayout.newTab().setText("Diamond"));
    tablayout.addTab(tablayout.newTab().setText("Gems Stone"));
    tablayout.addTab(tablayout.newTab().setText("Jewellery"));
    tablayout.setTabGravity(TabLayout.GRAVITY_FILL);

    setSupportActionBar(toolbaractionbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    fragmentManager = getFragmentManager();

    fragment = new DiamondFragment();

    if (fragment != null) {
      fragmentManager.beginTransaction().add(R.id.container_tab, fragment).commit();
    }
    tablayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            Log.d("tab position", String.valueOf(tab.getPosition()));

            switch (tab.getPosition()) {
              case 0:
                fragment = new DiamondFragment();

                if (fragment != null) {
                  fragmentManager
                      .beginTransaction()
                      .replace(R.id.container_tab, fragment)
                      .addToBackStack("Diamond")
                      .commit();
                }
                break;
              case 1:
                fragment = new GemsStoneFragment();

                if (fragment != null) {
                  fragmentManager
                      .beginTransaction()
                      .replace(R.id.container_tab, fragment)
                      .addToBackStack("GemsStones")
                      .commit();
                }
                break;
              case 2:
                fragment = new JewelleryFragment();

                if (fragment != null) {
                  fragmentManager
                      .beginTransaction()
                      .replace(R.id.container_tab, fragment)
                      .addToBackStack("Jewellery")
                      .commit();
                }
                Log.d("tab 2", "tab 2 selected");
                break;
            }
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });
  }
Ejemplo n.º 20
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tabs = (TabLayout) findViewById(R.id.tabs);

    List<String> titles = new ArrayList<>();
    List<Fragment> fragments = new ArrayList<>();

    String titlec = "职业生涯";
    tabs.addTab(tabs.newTab().setText(titlec));
    titles.add(titlec);
    Fragment fragment = new CareerF();
    fragments.add(fragment);

    String titled = "日记";
    tabs.addTab(tabs.newTab().setText(titled));
    titles.add(titled);
    Fragment fragmentd = new Diary();
    fragments.add(fragmentd);

    String titleb = "亲友生日";
    tabs.addTab(tabs.newTab().setText(titleb));
    titles.add(titleb);
    Fragment fragmentb = new Birthday();
    fragments.add(fragmentb);

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    TabLayViewPAdapter adapter =
        new TabLayViewPAdapter(getSupportFragmentManager(), titles, fragments);

    viewPager.setAdapter(adapter);
    tabs.setupWithViewPager(viewPager);
    tabs.setTabsFromPagerAdapter(adapter);
    tabs.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            index = tab.getPosition();
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });

    final FloatingActionButton actionButton = (FloatingActionButton) findViewById(R.id.bt_auction);
    actionButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            switch (index) {
              case 0:
                UIHelper.startAddCareer(MainActivity.this);
                break;
              case 1:
                break;
              case 2:
                UIHelper.startAddBirthday(MainActivity.this);
                break;
            }
          }
        });
  }
Ejemplo n.º 21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cardset_picker);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show();
          }
        });

    mViewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {
            tabLayout.getTabAt(position).select();
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });

    tabLayout = (TabLayout) findViewById(R.id.tabLayoutCardsetPicker);
    String[] mTabItems = getResources().getStringArray(R.array.tab_items_cardsetpicker);
    tabLayout.addTab(tabLayout.newTab().setText(mTabItems[0]));
    tabLayout.addTab(tabLayout.newTab().setText(mTabItems[1]));

    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            mViewPager.setCurrentItem(tab.getPosition());
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });

    cardsetPickerFragment = new SearchCardsetFragment();

    cardsetRecentsFragment = new RecentCardsetsFragment();

    memorizer.freecoders.com.flashcards.FragmentManager.intUIState = Constants.UI_STATE_CARD_PICK;

    Multicards.setCardsetPickerActivity(this);
  }