Blame view

PremiereActivite/app/src/main/java/com/example/app_10p5/MainActivite.java 2.01 KB
c8059613   JLo'w   Re-fonte de l'app...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  package com.example.app_10p5;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.design.widget.TabLayout;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.Fragment;
  import android.support.v4.view.ViewPager;
  import android.view.View;
  
  /**
   * Created by beaus on 24/04/2016.
   */
  public class MainActivite extends FragmentActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.layout_main);
          TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
          tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
          tabLayout.addTab(tabLayout.newTab().setText("Commande"));
          tabLayout.addTab(tabLayout.newTab().setText("Rechargement"));
          tabLayout.addTab(tabLayout.newTab().setText("Création"));
          tabLayout.addTab(tabLayout.newTab().setText("Vidange"));
          tabLayout.addTab(tabLayout.newTab().setText("Admin"));
          tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
  
          final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
          final PagerAdapter adapter = new PagerAdapter
                  (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) {
  
              }
          });
      }
  
      public void valideCommande(View v)
      {
          Intent intent = new Intent(this, CarteActivite.class);
          startActivity(intent);
      }
  }