Guest User

Untitled

a guest
Apr 30th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. /**
  2. * The {@link android.support.v4.view.PagerAdapter} that will provide
  3. * fragments for each of the sections. We use a
  4. * {@link FragmentPagerAdapter} derivative, which will keep every
  5. * loaded fragment in memory. If this becomes too memory intensive, it
  6. * may be best to switch to a
  7. * {@link android.support.v4.app.FragmentStatePagerAdapter}.
  8. */
  9. private SectionsPagerAdapter mSectionsPagerAdapter;
  10.  
  11. /**
  12. * The {@link ViewPager} that will host the section contents.
  13. */
  14. private ViewPager mViewPager;
  15. public RelativeLayout fondo,fondo2,fondo3;
  16.  
  17. @Override
  18. protected void onCreate(Bundle savedInstanceState) {
  19. super.onCreate(savedInstanceState);
  20. setContentView(R.layout.activity_main);
  21. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  22. setSupportActionBar(toolbar);
  23.  
  24.  
  25. // Create the adapter that will return a fragment for each of the three
  26. // primary sections of the activity.
  27. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
  28.  
  29. // Set up the ViewPager with the sections adapter.
  30. mViewPager = (ViewPager) findViewById(R.id.container);
  31. mViewPager.setAdapter(mSectionsPagerAdapter);
  32. TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
  33. tabLayout.setupWithViewPager(mViewPager);
  34. fondo=(RelativeLayout)findViewById(R.id.fondo);
  35. fondo2=(RelativeLayout)findViewById(R.id.fondo2);
  36. fondo3=(RelativeLayout)findViewById(R.id.fondo3);
  37.  
  38. }
  39.  
  40.  
  41. @Override
  42. public boolean onCreateOptionsMenu(Menu menu) {
  43. // Inflate the menu; this adds items to the action bar if it is present.
  44. getMenuInflater().inflate(R.menu.menu_main, menu);
  45. return true;
  46. }
  47.  
  48. @Override
  49. public boolean onOptionsItemSelected(MenuItem item) {
  50. // Handle action bar item clicks here. The action bar will
  51. // automatically handle clicks on the Home/Up button, so long
  52. // as you specify a parent activity in AndroidManifest.xml.
  53. Bundle datos=getIntent().getExtras();
  54. int id = item.getItemId();
  55.  
  56. //noinspection SimplifiableIfStatement
  57. if (id == R.id.cambiar_color){
  58. colorfondo();
  59. return true;
  60. }else if (id == R.id.acerca_de_la_app){
  61. ejecutarinfo();
  62. return true;
  63. }else if (id == R.id.acerca_del_autor){
  64. ejecutarautor();
  65. return true;
  66. }
  67.  
  68. return super.onOptionsItemSelected(item);
  69. }
  70. public void colorfondo(){
  71.  
  72. fondo.setBackgroundColor(Color.BLACK);
  73. fondo2.setBackgroundColor(Color.BLACK);
  74. fondo3.setBackgroundColor(Color.BLACK);
  75. }
Add Comment
Please, Sign In to add comment