Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * The {@link android.support.v4.view.PagerAdapter} that will provide
- * fragments for each of the sections. We use a
- * {@link FragmentPagerAdapter} derivative, which will keep every
- * loaded fragment in memory. If this becomes too memory intensive, it
- * may be best to switch to a
- * {@link android.support.v4.app.FragmentStatePagerAdapter}.
- */
- private SectionsPagerAdapter mSectionsPagerAdapter;
- /**
- * The {@link ViewPager} that will host the section contents.
- */
- private ViewPager mViewPager;
- public RelativeLayout fondo,fondo2,fondo3;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- // Create the adapter that will return a fragment for each of the three
- // primary sections of the activity.
- mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
- // Set up the ViewPager with the sections adapter.
- mViewPager = (ViewPager) findViewById(R.id.container);
- mViewPager.setAdapter(mSectionsPagerAdapter);
- TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
- tabLayout.setupWithViewPager(mViewPager);
- fondo=(RelativeLayout)findViewById(R.id.fondo);
- fondo2=(RelativeLayout)findViewById(R.id.fondo2);
- fondo3=(RelativeLayout)findViewById(R.id.fondo3);
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_main, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- Bundle datos=getIntent().getExtras();
- int id = item.getItemId();
- //noinspection SimplifiableIfStatement
- if (id == R.id.cambiar_color){
- colorfondo();
- return true;
- }else if (id == R.id.acerca_de_la_app){
- ejecutarinfo();
- return true;
- }else if (id == R.id.acerca_del_autor){
- ejecutarautor();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- public void colorfondo(){
- fondo.setBackgroundColor(Color.BLACK);
- fondo2.setBackgroundColor(Color.BLACK);
- fondo3.setBackgroundColor(Color.BLACK);
- }
Add Comment
Please, Sign In to add comment