Пример #1
1
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setupDrawer();
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
    MetricsManager.register(getApplication());

    mContext = this;

    if (mPreferences.useAutoSync()) {
      SyncScheduler.schedule(this, mPreferences.isRequiresCharging());
    }

    Intent i = getIntent();
    if (i != null) {
      mOpenChangelog = i.getBooleanExtra(EXTRA_FROM_NOTIFICATION, false);
      i.removeExtra(EXTRA_FROM_NOTIFICATION);
    }

    int filterId = Filters.TAB_ALL;
    if (savedInstanceState != null && !mOpenChangelog) {
      filterId = savedInstanceState.getInt("tab_id", Filters.TAB_ALL);
      AppLog.d("Restore tab: " + filterId);
    }

    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(mViewPager);
    mViewPager.setCurrentItem(filterId);

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

    mRefreshAnim = new MenuItemAnimation(this, R.anim.rotate);
  }
Пример #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mCoordinator = (CoordinatorLayout) findViewById(R.id.root_coordinator);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mToolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(mToolbar);

    navigationView = (NavigationView) findViewById(R.id.navigation_drawer);
    navigationView.setItemIconTintList(null);
    navigationView.setNavigationItemSelectedListener(this);

    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    mAdapter = new TabPagerAdapter(this, getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.view_pager);
    mPager.setAdapter(mAdapter);
    // Notice how the Tab Layout links with the Pager Adapter
    mTabLayout.setTabsFromPagerAdapter(mAdapter);

    // Notice how The Tab Layout adn View Pager object are linked
    mTabLayout.setupWithViewPager(mPager);
    mPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
    if (getIntent() != null) {
      mPager.setCurrentItem(getIntent().getIntExtra("tab", 0));
    }
    fragmentManager = getSupportFragmentManager();
  }
Пример #3
0
  private void initView() {
    mCurrentTabIndex = 0;
    mTabTitles =
        new String[] {
          mActivity.getResources().getString(R.string.ml_chat),
          mActivity.getResources().getString(R.string.ml_contacts),
          mActivity.getResources().getString(R.string.ml_test)
        };

    mContactsFragment = MLContactsFragment.newInstance();
    mConversationFragment = MLConversationsFragment.newInstance();
    mTestFragment = MLTestFragment.newInstance();

    mFragments = new Fragment[] {mConversationFragment, mContactsFragment, mTestFragment};
    MLViewPagerAdapter adapter =
        new MLViewPagerAdapter(getSupportFragmentManager(), mFragments, mTabTitles);
    mViewPager.setAdapter(adapter);
    mViewPager.setCurrentItem(mCurrentTabIndex);
    mViewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {
            getToolbar().setTitle(mTabTitles[position]);
          }

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

    mTabLayout.setupWithViewPager(mViewPager);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // 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);

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

    Intent get_weight = getIntent();

    Bundle extras = get_weight.getExtras();
    if (extras != null) {
      weight_input = extras.getString("weight").toString();

      //            System.out.println(weight_input);

    }
  }
 private void setUpTabLayoutAndViewPager() {
   ContentPagerAdapter contentPagerAdapter = new ContentPagerAdapter(getSupportFragmentManager());
   mViewPager.setAdapter(contentPagerAdapter);
   mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
   mTabLayout.setTabsFromPagerAdapter(contentPagerAdapter);
   mTabLayout.setupWithViewPager(mViewPager);
 }
  @UiThread
  void setupViewPager() {
    adapter = new MainPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);

    tabs.setupWithViewPager(pager);
  }
Пример #7
0
 private void setupTablayout() {
   tabLayout = (TabLayout) findViewById(R.id.tabLayout);
   tabLayout.setupWithViewPager(viewPager);
   // 如果是三个,则是下面的固定的模式
   // tabLayout.setTabMode(TabLayout.MODE_FIXED);
   tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
 }
Пример #8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_library);
    setTitle(R.string.title_activity_library);

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

    // Page adapter
    SectionsPagerAdapter sectionsPagerAdapter =
        new SectionsPagerAdapter(getSupportFragmentManager());
    ViewPager viewPager = (ViewPager) findViewById(R.id.container);
    viewPager.setAdapter(sectionsPagerAdapter);

    initActivityState();

    // Media service
    Intent intent = new Intent(this, MediaService.class);
    startService(intent);

    // Tabs
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);

    // TODO: Attach a content observer to listen for MediaStore changes.
    //       This will require changes to many components to deal with all the edge cases.
    //       There may be some noise around this as it appears the observer is notified when
    //       tracks are simply accessed.
  }
Пример #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general_activity);

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

    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
      setupDrawerContent(navigationView);
    }

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
      setupViewPager(viewPager);
    }

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_detail);
    ButterKnife.bind(this);
    // 设置切换activity对应的控件
    ViewCompat.setTransitionName(imgAvatar, NAME_IMG_AVATAR);

    // 设置头像
    String avatarUrl = getIntent().getStringExtra("avatarUrl");
    if (!TextUtils.isEmpty(avatarUrl)) {
      Picasso.with(this).load(avatarUrl).placeholder(R.drawable.image_placeholder).into(imgAvatar);
    }
    // 用户名
    loginName = getIntent().getStringExtra("loginName");
    if (!TextUtils.isEmpty(loginName)) {
      tvLoginName.setText(loginName);
    }

    adapter = new ViewPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(adapter);
    viewPager.setOffscreenPageLimit(adapter.getCount());
    tabLayout.setupWithViewPager(viewPager);

    getUserAsyncTask();
  }
Пример #11
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRoot = inflater.inflate(R.layout.rank_dialog, container, false);

    ViewGroup.LayoutParams lp = mRoot.findViewById(R.id.rank_layout).getLayoutParams();
    lp.width = getContext().getResources().getDisplayMetrics().widthPixels * 3 / 4;
    lp.height = getContext().getResources().getDisplayMetrics().heightPixels * 3 / 4;
    mRoot.findViewById(R.id.rank_layout).setLayoutParams(lp);

    viewPager = (ViewPager) mRoot.findViewById(R.id.rank_viewpager);
    pagerAdapter = new ViewPagerAdapter(getChildFragmentManager());
    tabLayout = (TabLayout) mRoot.findViewById(R.id.rank_tablayout);

    initFragment();
    viewPager.setAdapter(pagerAdapter);

    tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.Golden));

    // viewPager.addOnPageChangeListener(new
    // TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    // tabLayout.setOnTabSelectedListener(new
    // TabLayout.ViewPagerOnTabSelectedListener(viewPager));

    tabLayout.setupWithViewPager(viewPager);

    mRoot.findViewById(R.id.left_btn).setOnClickListener(this);
    mRoot.findViewById(R.id.right_btn).setOnClickListener(this);

    return mRoot;
  }
Пример #12
0
 @Override
 public void onViewCreated(View view, Bundle savedInstanceState) {
   super.onViewCreated(view, savedInstanceState);
   setupViewPager(viewPager);
   tabLayout.setupWithViewPager(viewPager);
   updateToolbar();
 }
Пример #13
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    try {
      super.onCreate(savedInstanceState);
    } catch (BaseActivity.GoodException e) {
      return;
    }
    setContentView(R.layout.activity_repository);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
    pager = (ViewPager) findViewById(R.id.viewPager);
    aAdapter = new AAdapter(getSupportFragmentManager());
    pager.setAdapter(aAdapter);
    tabLayout.setupWithViewPager(pager);
    Log.d(RepositoryActivity.class.getName(), "onCreate activity=" + this);
    if (savedInstanceState == null) {
      if (getIntent().getBooleanExtra(EXTRA_IS_FIRST_IN, false)) {
        pager.setCurrentItem(2);
        new LeadDialog().show(getFragmentManager(), LeadDialog.class.getName());
      }
    }
  }
Пример #14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_route);

    viewPager = (ViewPager) findViewById(R.id.rviewpager);
    setupViewPager(viewPager);
    tabLayout = (TabLayout) findViewById(R.id.rtabs);
    tabLayout.setupWithViewPager(viewPager);

    setupTabIcons();

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

          // This is when the user pushes one of the tabs.
          @Override
          public void onPageSelected(int position) {
            if (position == 0) {
            } else if (position == 1) {
            } else if (position == 2) {
            }
          }
          // Just for the future.
          @Override
          public void onPageScrollStateChanged(int state) {}
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_swipe_tabs);

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

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    viewPager = (ViewPager) findViewById(R.id.pager);
    setupViewPager(viewPager);

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

    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            // do something you want
            close();
          }
        });
  }
Пример #16
0
 // 初始化tablayout
 private void initTab() {
   viewPager = (ViewPager) findViewById(R.id.viewPager);
   tabLayout = (TabLayout) findViewById(R.id.tabLayout);
   MainPagerAdapter pagerAdapter = new MainPagerAdapter(getSupportFragmentManager());
   viewPager.setAdapter(pagerAdapter);
   tabLayout.setupWithViewPager(viewPager);
 }
Пример #17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // 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);

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

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent intent = new Intent(view.getContext(), StatisticsActivity.class);
            startActivity(intent);
          }
        });
  }
Пример #18
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recommend);
    SwipeBackHelper.getCurrentPage(this).setSwipeBackEnable(false);
    ButterKnife.bind(this);
    back.setOnClickListener(v -> finish());
    viewpager.setAdapter(pagerAdapter = new SeedFragmentListAdapter(getSupportFragmentManager()));
    tabs.setupWithViewPager(viewpager);
    viewpager.setCurrentItem(getIntent().getIntExtra("type", 0));
    tabs.setTabTextColors(
        getResources().getColor(R.color.gray), getResources().getColor(R.color.orange));
    tabs.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            title.setText(tab.getText());
          }

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

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });
  }
Пример #19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fikirinawesib7);

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

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    viewPager = (ViewPager) findViewById(R.id.viewpager21);
    setupViewPager(viewPager);

    tabLayout = (TabLayout) findViewById(R.id.tabs21);
    tabLayout.setupWithViewPager(viewPager);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("vnd.android-dir/mms-sms");
            intent.putExtra("address", "+251911202110");
            intent.putExtra("sms_body", "ሜሴጆን ይጻፉ!!!");
            startActivity(intent);
          }
        });
  }
  private void init() {
    mTabTitles = new String[] {"FirstFragmetn", "SecondFragment", "ThirdFragment"};

    firstFragment = new MLFirstFragment();
    secondFragment = new MLSecondFragment();
    thirdFragment = new MLThirdFragment();
    mFragments = new Fragment[] {firstFragment, secondFragment, thirdFragment};

    mAdapter = new MLFragmentPagerAdapter(getSupportFragmentManager(), mTabTitles, mFragments);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setCurrentItem(0);
    // 设置 ViewPager 预加载数量
    mViewPager.setOffscreenPageLimit(3);
    // 添加 ViewPager 页面改变监听
    mViewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {}

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

    mTabLayout.setupWithViewPager(mViewPager);
  }
Пример #21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // 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);

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

    /** * Begin generating dummy data for In-Memory implementation ** */

    //        expenseManager = new InMemoryDemoExpenseManager();
    expenseManager = new PersistentExpenseManager();

    /** * END ** */
  }
  private void setUpPagerAndTabs() {
    pager = (ViewPager) findViewById(R.id.pager);
    pagerAdapter =
        new StreamMediaPlayerPagerAdapter(StreamVideoActivity.this, getSupportFragmentManager());
    pager.setAdapter(pagerAdapter);
    pager.setOffscreenPageLimit(2);
    tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.setTabsFromPagerAdapter(pagerAdapter);
    tabLayout.setupWithViewPager(pager);
    tabLayout.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
            pager.setCurrentItem(tab.getPosition());
          }

          @Override
          public void onTabUnselected(TabLayout.Tab tab) {
            if (tab.getPosition() == 0) {
              pagerAdapter.mFragment.hideAll();
            }
          }

          @Override
          public void onTabReselected(TabLayout.Tab tab) {}
        });
  }
Пример #23
0
  private void initViewPager() {
    viewPagerAdapter =
        AdapterLess.$pager(
            getSupportFragmentManager(),
            getResources().getStringArray(R.array.must_titles).length,
            new AdapterLess.FullFragmentPagerCallBack() {
              @Override
              public Fragment getItem(int i) {
                Fragment fragment;
                if (i == 0) {
                  fragment = new MustListFragment();
                } else if (i == 1) {
                  fragment = new MustListFragment();
                } else {
                  fragment = new HomeDigestListFragment();
                }
                return fragment;
              }

              @Override
              public String getPageTitle(int i) {
                return getResources().getStringArray(R.array.must_titles)[i];
              }
            });
    viewPager.setOffscreenPageLimit(3);
    viewPager.setAdapter(viewPagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
  }
Пример #24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Utils.showUpdateDialogIfNecessary(this);
    setContentView(R.layout.activity_repcast);
    if (savedInstanceState == null) {
      mPagerAdapter =
          new RepcastPageAdapter(getSupportFragmentManager(), this, getApplicationContext());
    } else {
      mBackSelectFileFragments.addAll(
          Arrays.asList(savedInstanceState.getParcelableArray(INSTANCE_STATE_BACK_STACK_FILES)));
      mBackTorrentFragments.addAll(
          Arrays.asList(savedInstanceState.getParcelableArray(INSTANCE_STATE_BACK_STACK_TORRENTS)));
      mPagerAdapter =
          new RepcastPageAdapter(
              getSupportFragmentManager(),
              getApplicationContext(),
              (JsonDirectory.JsonFileDir) mBackSelectFileFragments.peek(),
              (JsonTorrent.JsonTorrentResult) mBackTorrentFragments.peek());
    }
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setCurrentItem(RepcastPageAdapter.FILE_INDEX);
    mViewPager.addOnPageChangeListener(this);

    completeOnCreate(savedInstanceState, true);
    tabLayout.setupWithViewPager(mViewPager);
  }
Пример #25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // ROTAZIONE SCHERMO BLOCCATA
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    viewPager = (ViewPager) findViewById(R.id.viewpagerHome);
    setupViewPager(viewPager);

    tabLayout = (TabLayout) findViewById(R.id.tabsHome);
    tabLayout.setupWithViewPager(viewPager);

    setTitle("Home");
  }
Пример #26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.yaya_main_aty);

    ym_toolbar = (Toolbar) findViewById(R.id.ym_toolbar);
    initTitle(ym_toolbar);

    setUpDrawerToggle();

    //        yaya_main_rv = (RecyclerView) findViewById(R.id.yaya_main_rv);
    //        YaYaMainRecyclerAdapter adapter = new YaYaMainRecyclerAdapter();
    //        yaya_main_rv.setAdapter(adapter);
    //        yaya_main_rv.setLayoutManager(new LinearLayoutManager(this));

    ym_view_pager = (ViewPager) findViewById(R.id.ym_viewpager);

    YMPagerAdapter pagerAdapter = new YMPagerAdapter(getSupportFragmentManager());
    pagerAdapter.addFragment(new YaYaTravelNoteFg(), "游记");
    pagerAdapter.addFragment(new YaYaTravelNoteFg(), "音乐");
    pagerAdapter.addFragment(new YaYaTravelNoteFg(), "英语");
    ym_view_pager.setAdapter(pagerAdapter);
    ym_tablayout = (TabLayout) findViewById(R.id.ym_tablayout);
    ym_tablayout.setupWithViewPager(ym_view_pager);
  }
Пример #27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_touristic_point);

    // Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.WHITE);
    toolbar.setSubtitleTextColor(Color.WHITE);
    setSupportActionBar(toolbar);

    // Create the adapter that will return a fragment for each of the 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);
    mViewPager.addOnPageChangeListener(this);

    // Tabs
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    // Recebendo dados da outra activity
    Intent intent = getIntent();
    int id = intent.getExtras().getInt("id");
    touristicPoint = DatabaseDAO.getInstance().getTouristicPointByID(id);
  }
Пример #28
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // 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);

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

    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();
          }
        });
  }
Пример #29
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_info);

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

    // Back button
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
    }

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

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

    // Set title if object exists.
    MalwareObject malwareObject = getIntent().getExtras().getParcelable("malware");
    if (malwareObject != null) {
      getSupportActionBar().setTitle(malwareObject.getName());
    }
  }
Пример #30
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

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

    // getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);

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

    mFloat = (FloatingActionButton) findViewById(R.id.fab);
    mFloat.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, AddTask.class);
            startActivity(intent);
          }
        });
  }