Advertisement
Rapptz

Untitled

Feb 19th, 2014
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. package com.basic.hello.world.app;
  2.  
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.support.v7.app.ActionBar;
  5. import android.support.v4.app.Fragment;
  6. import android.os.Bundle;
  7. import android.view.LayoutInflater;
  8. import android.view.Menu;
  9. import android.view.MenuItem;
  10. import android.view.View;
  11. import android.view.ViewGroup;
  12. import android.os.Build;
  13.  
  14. public class MainActivity extends ActionBarActivity {
  15.  
  16.     @Override
  17.     protected void onCreate(Bundle savedInstanceState) {
  18.         super.onCreate(savedInstanceState);
  19.         setContentView(R.layout.activity_main);
  20.  
  21.         if (savedInstanceState == null) {
  22.             getSupportFragmentManager().beginTransaction()
  23.                     .add(R.id.container, new PlaceholderFragment())
  24.                     .commit();
  25.         }
  26.     }
  27.  
  28.  
  29.     @Override
  30.     public boolean onCreateOptionsMenu(Menu menu) {
  31.        
  32.         // Inflate the menu; this adds items to the action bar if it is present.
  33.         getMenuInflater().inflate(R.menu.main, menu);
  34.         return true;
  35.     }
  36.  
  37.     @Override
  38.     public boolean onOptionsItemSelected(MenuItem item) {
  39.         // Handle action bar item clicks here. The action bar will
  40.         // automatically handle clicks on the Home/Up button, so long
  41.         // as you specify a parent activity in AndroidManifest.xml.
  42.         int id = item.getItemId();
  43.         if (id == R.id.action_settings) {
  44.             return true;
  45.         }
  46.         return super.onOptionsItemSelected(item);
  47.     }
  48.  
  49.     /**
  50.      * A placeholder fragment containing a simple view.
  51.      */
  52.     public static class PlaceholderFragment extends Fragment {
  53.  
  54.         public PlaceholderFragment() {
  55.         }
  56.  
  57.         @Override
  58.         public View onCreateView(LayoutInflater inflater, ViewGroup container,
  59.                 Bundle savedInstanceState) {
  60.             View rootView = inflater.inflate(R.layout.fragment_main, container, false);
  61.             return rootView;
  62.         }
  63.     }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement