Guest User

Untitled

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