Advertisement
Guest User

Main

a guest
Mar 10th, 2014
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.src.vicnote;
  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.content.Intent;
  7.     import android.os.Bundle;
  8.     import android.view.LayoutInflater;
  9.     import android.view.Menu;
  10.     import android.view.MenuItem;
  11.     import android.view.View;
  12.     import android.view.ViewGroup;
  13.     import android.widget.Button;
  14.     import android.os.Build;
  15.      
  16.     public class MainActivity extends ActionBarActivity {
  17.      
  18.             Button newButton;
  19.            
  20.         @Override
  21.         protected void onCreate(Bundle savedInstanceState) {
  22.             super.onCreate(savedInstanceState);
  23.             setContentView(R.layout.activity_main);
  24.      
  25.             newButton = (Button) findViewById(R.id.buttonNew);
  26.             newButton.setOnClickListener(new View.OnClickListener() {
  27.                            
  28.                             @Override
  29.                             public void onClick(View v) {
  30.                                     // TODO Auto-generated method stub
  31.                                    
  32.                                     Intent newNote = new Intent(MainActivity.this, NewNoteActivity.class);
  33.                                     startActivity(newNote);
  34.                             }
  35.                     });
  36.            
  37.             if (savedInstanceState == null) {
  38.                 getSupportFragmentManager().beginTransaction()
  39.                         .add(R.id.container, new PlaceholderFragment())
  40.                         .commit();
  41.             }
  42.         }
  43.      
  44.      
  45.         @Override
  46.         public boolean onCreateOptionsMenu(Menu menu) {
  47.            
  48.             // Inflate the menu; this adds items to the action bar if it is present.
  49.             getMenuInflater().inflate(R.menu.main, menu);
  50.             return true;
  51.         }
  52.      
  53.         @Override
  54.         public boolean onOptionsItemSelected(MenuItem item) {
  55.             // Handle action bar item clicks here. The action bar will
  56.             // automatically handle clicks on the Home/Up button, so long
  57.             // as you specify a parent activity in AndroidManifest.xml.
  58.             int id = item.getItemId();
  59.             if (id == R.id.action_settings) {
  60.                 return true;
  61.             }
  62.             return super.onOptionsItemSelected(item);
  63.         }
  64.      
  65.         /**
  66.          * A placeholder fragment containing a simple view.
  67.          */
  68.         public static class PlaceholderFragment extends Fragment {
  69.      
  70.             public PlaceholderFragment() {
  71.             }
  72.      
  73.             @Override
  74.             public View onCreateView(LayoutInflater inflater, ViewGroup container,
  75.                     Bundle savedInstanceState) {
  76.                 View rootView = inflater.inflate(R.layout.fragment_main, container, false);
  77.                 return rootView;
  78.             }
  79.         }
  80.      
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement