Advertisement
Guest User

Untitled

a guest
Feb 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:id="@+id/drawer"
  6. android:layout_width="match_parent"
  7. android:layout_height="match_parent"
  8. tools:context="net.rhyboo.com.drawer_test.MainActivity">
  9.  
  10. <LinearLayout
  11. android:layout_width="match_parent"
  12. android:layout_height="match_parent"
  13. android:orientation="vertical">
  14. </LinearLayout>
  15.  
  16. <net.rhyboo.com.drawer_test.PuzzlePagerView
  17. android:layout_gravity="start"
  18. android:layout_height="match_parent"
  19. android:layout_width="240dp"
  20. android:background="@android:color/white"
  21. android:id="@+id/pager">
  22. </net.rhyboo.com.drawer_test.PuzzlePagerView>
  23.  
  24. public class MainActivity extends AppCompatActivity {
  25.  
  26. @Override
  27. protected void onCreate(Bundle savedInstanceState) {
  28. super.onCreate(savedInstanceState);
  29. setContentView(R.layout.activity_main);
  30. DrawerLayout drawer=(DrawerLayout) findViewById(R.id.drawer);
  31. drawer.setScrimColor(getResources().getColor(R.color.gameMenuDim));
  32. PuzzlePagerView pager=(PuzzlePagerView)findViewById(R.id.pager);
  33. GameMenuPagerAdapter menuAdapter=new GameMenuPagerAdapter(getSupportFragmentManager());
  34. pager.setAdapter(menuAdapter);
  35. }
  36. }
  37.  
  38. public class GameMenuPagerAdapter extends FragmentPagerAdapter {
  39. private GameMenuFragment gameMenu;
  40. public GameMenuPagerAdapter(FragmentManager fm) {
  41. super(fm);
  42. gameMenu=new GameMenuFragment();
  43. }
  44. @Override
  45. public Fragment getItem(int position) {
  46. Log.d("pager",position+"");
  47. switch (position) {
  48. case 0:
  49. return gameMenu;
  50. }
  51. return null;
  52. }
  53.  
  54. @Override
  55. public int getCount() {
  56. return 1;
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement