SHOW:
|
|
- or go back to the newest paste.
1 | - | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
1 | + | package com.src.vicnote; |
2 | - | xmlns:tools="http://schemas.android.com/tools" |
2 | + | |
3 | - | android:id="@+id/MainScreen" |
3 | + | import android.support.v7.app.ActionBarActivity; |
4 | - | android:layout_width="match_parent" |
4 | + | import android.support.v7.app.ActionBar; |
5 | - | android:layout_height="match_parent" |
5 | + | import android.support.v4.app.Fragment; |
6 | - | android:paddingBottom="@dimen/activity_vertical_margin" |
6 | + | import android.content.Intent; |
7 | - | android:paddingLeft="@dimen/activity_horizontal_margin" |
7 | + | import android.os.Bundle; |
8 | - | android:paddingRight="@dimen/activity_horizontal_margin" |
8 | + | import android.view.LayoutInflater; |
9 | - | android:paddingTop="@dimen/activity_vertical_margin" |
9 | + | import android.view.Menu; |
10 | - | tools:context="com.src.vicnote.MainActivity$PlaceholderFragment" > |
10 | + | import android.view.MenuItem; |
11 | - | |
11 | + | import android.view.View; |
12 | - | <Button |
12 | + | import android.view.ViewGroup; |
13 | - | android:id="@+id/buttonNew" |
13 | + | import android.widget.Button; |
14 | - | style="?android:attr/buttonStyleSmall" |
14 | + | import android.os.Build; |
15 | - | android:layout_width="wrap_content" |
15 | + | |
16 | - | android:layout_height="wrap_content" |
16 | + | public class MainActivity extends ActionBarActivity { |
17 | - | android:layout_alignParentRight="true" |
17 | + | |
18 | - | android:layout_alignParentTop="true" |
18 | + | Button newButton; |
19 | - | android:text="New" /> |
19 | + | |
20 | - | |
20 | + | @Override |
21 | - | </RelativeLayout> |
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 | } |