コード例 #1
0
 private void insertarTabs(ViewGroup container) {
   View padre = (View) container.getParent();
   appBar = (AppBarLayout) padre.findViewById(R.id.appbar);
   pestanas = new TabLayout(getActivity());
   pestanas.setTabTextColors(Color.parseColor("#FFFFFF"), Color.parseColor("#FFFFFF"));
   appBar.addView(pestanas);
 }
コード例 #2
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) {}
        });
  }
コード例 #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_joc__ranking);

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    // viewPager.setAdapter(new PagerAdapter(getFragmentManager(), PagerHolder.this));       Para
    // fragments normales
    viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager())); // Solo para MATERIAL

    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setTabTextColors(
        Color.DKGRAY, Color.BLACK); // Per canviar el color de la pestanya a on estas
    tabLayout.setupWithViewPager(viewPager);
  }
コード例 #4
0
ファイル: TradingTab.java プロジェクト: PutraJuke/OlahDana
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_trading_tab);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_trad);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

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

    tabLayout = (TabLayout) findViewById(R.id.tabs_trading);
    tabLayout.setBackgroundColor(getResources().getColor(R.color.icons));
    tabLayout.setTabTextColors(
        getResources().getColor(R.color.md_blue_grey_500),
        getResources().getColor(R.color.primary));
    tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.md_blue_grey_500));
    tabLayout.setupWithViewPager(viewPager);
  }
コード例 #5
0
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    distance = (Distance) getArguments().getSerializable(ITEM);

    View rootView = inflater.inflate(R.layout.fragment_distance, container, false);

    ViewPager viewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
    DistanceTabsFragmentPagerAdapter adapter =
        new DistanceTabsFragmentPagerAdapter(getActivity(), distance);
    viewPager.setAdapter(adapter);
    int item = distance.unit.equals(Distance.METER) ? 0 : 1;
    viewPager.setCurrentItem(item, false);

    TabLayout tabLayout = (TabLayout) rootView.findViewById(R.id.sliding_tabs);
    tabLayout.setTabTextColors(0xCCFFFFFF, Color.WHITE);
    tabLayout.setupWithViewPager(viewPager);

    FloatingActionButton mFab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    mFab.setOnClickListener(this);

    return rootView;
  }
コード例 #6
0
  private void init() {
    if (tittles == null) {
      tittles = new String[] {"动态", "活动", "榜单"};
    }
    if (fragments == null) {
      fragments = new ArrayList<>();
      fragments.add(new DynewestFragment());
      fragments.add(new SubActivityFragment());
      fragments.add(new SublistrankFragment());
    }
    communityFansNumber = (TextView) findViewById(R.id.community_people_number);
    communityBossName = (TextView) findViewById(R.id.community_boss_name);

    groupHead = (ImageView) findViewById(R.id.community_head);
    groupName = (TextView) findViewById(R.id.community_name);
    sign = (TextView) findViewById(R.id.community_sign);
    activitySignIn = (TextView) findViewById(R.id.activity_sign);
    activityLunch = (TextView) findViewById(R.id.lunch_activity);

    Drawable drawable1 = ContextCompat.getDrawable(this, R.mipmap.ic_fans);
    drawable1.setBounds(0, 0, DensityUtil.dip2px(this, 23f), DensityUtil.dip2px(this, 23f));
    communityFansNumber.setCompoundDrawables(drawable1, null, null, null);

    Drawable drawable2 = ContextCompat.getDrawable(this, R.mipmap.ic_person);
    drawable2.setBounds(0, 0, DensityUtil.dip2px(this, 23f), DensityUtil.dip2px(this, 23f));
    communityBossName.setCompoundDrawables(drawable2, null, null, null);

    tabLayout = (TabLayout) findViewById(R.id.tool_bar);
    tabLayout.setTabTextColors(Color.parseColor("#6c6c6c"), Color.parseColor("#6dc396"));

    viewPager = (ViewPager) findViewById(R.id.my_pager);
    viewPager.setAdapter(new MyAdapter(getSupportFragmentManager()));
    tabLayout.setupWithViewPager(viewPager);
    // ========================================获取网络数据

    // ========================================
  }
コード例 #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    /*
    Views
    */
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    list = (ListView) findViewById(R.id.listView);
    webView = (WebView) findViewById(R.id.webView);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    tabs = (TabLayout) findViewById(R.id.tabs);

    /*
    Tabs
    */
    // Tabs are invisible
    hideTabs();

    // Listener to receive tab changes
    tabs.setOnTabSelectedListener(
        new TabLayout.OnTabSelectedListener() {

          // User selected new tab
          @Override
          public void onTabSelected(TabLayout.Tab tab) {

            // Find page
            for (Pages p : Pages.values()) {
              if (p.title.equals(actual.title)) {

                // Load URL in webview
                if (actual.url != null) actual.actualURL = p.url.split("\\|\\|")[tab.getPosition()];
                if (actual.localPage != null)
                  actual.actualAlternativeURL = actual.localPage.split("\\|\\|")[tab.getPosition()];
              }
            }
            if (actual.url != null) {
              webView.loadUrl(actual.actualURL);
            } else {
              if (actual.localPage != null)
                webView.loadUrl("file:///android_asset/" + actual.actualAlternativeURL);
            }
          }

          // We don't need this methods
          @Override
          public void onTabUnselected(TabLayout.Tab tab) {}

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

    /*
    Drawer items
    */

    // Create list of all items for the drawer
    final ArrayList<Pages> pages = new ArrayList<Pages>();
    for (Pages p : Pages.values()) {
      if (p.menu == false) pages.add(p);
    }

    // Set actual page to the first item
    if (actual == null) {
      actual = pages.get(0);
    }

    /*
    White design
    */
    if (actual.useWhiteFont) {
      toolbar.setTitleTextColor(0xFFFFFFFF);
      tabs.setTabTextColors(0xFFFFFFFF, 0xFFFFFFFF);
    }

    /*
    Toolbar
    */
    toolbar.setTitle(actual.title);
    setSupportActionBar(toolbar);

    /*
    Admob
    */
    AdView mAdView = (AdView) findViewById(R.id.adView);

    // Hide AdView when not needed
    if (!actual.useAds) {
      mAdView.setVisibility(View.INVISIBLE);
    } else {
      // Init AdView when needed
      AdRequest adRequest = new AdRequest.Builder().build();
      mAdView.loadAd(adRequest);
    }

    /*
    Drawer
    */
    ActionBarDrawerToggle mDrawerToggle =
        new ActionBarDrawerToggle(
            this,
            drawerLayout,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawerLayout.setDrawerListener(mDrawerToggle);
    drawerLayout.setDrawerShadow(R.drawable.shadow, Gravity.LEFT);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    mDrawerToggle.syncState();

    /*
    Pages to drawer
    */

    // Add pages to the drawer
    ListAdapter adapter = new ListAdapter(this, pages);
    list.setAdapter(adapter);
    adapter.notifyDataSetChanged();

    /*
    Webview
    */
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(
        new WebViewClient() {

          // Handle URL loading
          // Handle Intents (e.g. mailto:)
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if ((url.contains("http:") || url.contains("https:"))
                && actual.homeDomains.contains(URI.create(url).getHost())) {
              view.loadUrl(url);
              return false;
            } else {
              Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
              PackageManager manager = getPackageManager();
              List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);
              if (infos.size() > 0) {
                startActivity(intent);
              }
              return true;
            }
          }

          // Needed for correct back-button functionality
          @Override
          public void onPageFinished(WebView view, String url) {
            webView.clearHistory();
            super.onPageFinished(view, url);
          }

          // Handle loading errors
          @Override
          public void onReceivedError(
              WebView view, int errorCode, String description, String failingUrl) {
            if (actual.actualAlternativeURL != null)
              webView.loadUrl("file:///android_asset/" + actual.actualAlternativeURL);
            else view.loadData(actual.error, "text/html", actual.localEncoding);
          }
        });

    /*
    Site listener
    */

    // Change page via drawer
    list.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            changePage(pages.get(position));
          }
        });

    /*
    Update
    */

    // Load actual (first) page
    changePage(actual);
  }