SHARE
TWEET

Untitled

a guest Jun 15th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private DrawerLayout dr;
  2.     private ActionBarDrawerToggle toggle;
  3.  
  4.     @Override
  5.     protected void onCreate(Bundle savedInstanceState) {
  6.         super.onCreate(savedInstanceState);
  7.         requestWindowFeature(Window.FEATURE_ACTION_BAR);
  8.         setContentView(R.layout.activity_main2);
  9.  
  10.        //drawerLayout
  11.         dr=(DrawerLayout)findViewById(R.id.draw);
  12.        toggle=new ActionBarDrawerToggle(this,dr,R.string.Open,R.string.Close);
  13.  
  14.        dr.addDrawerListener(toggle);
  15.        NavigationView navigationView =(NavigationView)findViewById(R.id.navigate);
  16.        toggle.syncState();
  17.        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  18.         SetUpDrawer(navigationView);
  19. }
  20.      
  21. @Override
  22.     public boolean onOptionsItemSelected(MenuItem item)
  23.     {
  24.         if(toggle.onOptionsItemSelected(item))
  25.         {
  26.             return true;
  27.         }
  28.         return super.onOptionsItemSelected(item);
  29.     }
  30.     public void selectDrawer(MenuItem menu)
  31.     {
  32.         Fragment myfragmenet =null;
  33.         Class FragmentClass = null;
  34.         switch (menu.getItemId())
  35.         {
  36.             case R.id.VoirHotel:
  37.                 FragmentClass=Hotels.class;
  38.                 break;
  39.             case R.id.filter:
  40.                 FragmentClass=Filter.class;
  41.                 break;
  42.             case R.id.carte:
  43.                 FragmentClass=Maps.class;
  44.         }
  45.         try {
  46.             myfragmenet=(Fragment)FragmentClass.newInstance();
  47.         } catch (Exception e) {
  48.             e.printStackTrace();
  49.         }
  50.         FragmentManager fragmentManager=getSupportFragmentManager();
  51.         fragmentManager.beginTransaction().replace(R.id.fcontent,myfragmenet).commit();
  52.         menu.setChecked(true);
  53.         setTitle(menu.getTitle());
  54.         dr.closeDrawers();
  55.     }
  56.     private void SetUpDrawer(NavigationView navigater)
  57.     {
  58.         navigater.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
  59.             @Override
  60.             public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
  61.                 selectDrawer(menuItem);
  62.                 return true;
  63.             }
  64.         });
  65.     }
  66.  
  67. }
  68.      
  69. @Override
  70.     public View onCreateView(LayoutInflater inflater, ViewGroup container,
  71.                              Bundle savedInstanceState) {
  72.         // Inflate the layout for this fragment
  73.         mView=inflater.inflate(R.layout.fragment_maps, container, false);
  74.         return mView;
  75.     }
  76.  
  77.     @Override
  78.     public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  79.         super.onViewCreated(view, savedInstanceState);
  80.         MapFragment  mapFragment=(MapFragment) getChildFragmentManager().findFragmentById(R.id.map);
  81.         mapFragment.getMapAsync(this);
  82.     }
  83.  
  84.     @Override
  85.     public void onMapReady(GoogleMap googleMap) {
  86.         MapsInitializer.initialize(getContext());
  87.         mGoogleMap = googleMap;
  88.         googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
  89.         googleMap.addMarker(new MarkerOptions().position(new LatLng(36.7331,3.1567)).title("Hotel Hilton").snippet("Babez"));
  90.         CameraPosition lib = CameraPosition.builder().target(new LatLng(36.7194,3.1405)).zoom(16).bearing(0).tilt(45).build();
  91.         googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(lib));
  92.     }
  93.    }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top