Commit | Line | Data |
---|---|---|
5cf4714f | 1 | package ro.ieval.unical; |
6d7e08bf | 2 | import android.app.ActionBar; |
5cf4714f | 3 | import android.app.Activity; |
e6ba41a8 | 4 | import android.app.DialogFragment; |
6d7e08bf | 5 | import android.app.Fragment; |
5cf4714f | 6 | import android.os.Bundle; |
6d7e08bf PT |
7 | import android.view.Menu; |
8 | import android.view.MenuInflater; | |
9 | import android.view.MenuItem; | |
e6ba41a8 | 10 | import android.view.View; |
5cf4714f MG |
11 | |
12 | public final class AddEventActivity extends Activity { | |
13 | @Override | |
14 | protected void onCreate(final Bundle savedInstanceState) { | |
15 | super.onCreate(savedInstanceState); | |
16 | setContentView(R.layout.add_event); | |
ecee6932 | 17 | setTitle(R.string.addeventtitle); |
724f9857 | 18 | final ActionBar actionBar = getActionBar(); |
6d7e08bf | 19 | actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); |
724f9857 MG |
20 | final ActionBar.Tab t1 = actionBar.newTab().setText(this.getString(R.string.addevtab1)); |
21 | final ActionBar.Tab t2 = actionBar.newTab().setText(this.getString(R.string.addevtab2)); | |
22 | final ActionBar.Tab t3 = actionBar.newTab().setText(this.getString(R.string.addevtab3)); | |
6d7e08bf | 23 | |
88ba7fcf MG |
24 | final Fragment f1 = new TrivialFragment(); |
25 | final Bundle b1=new Bundle(); | |
26 | b1.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_basic_tab); | |
27 | f1.setArguments(b1); | |
28 | ||
29 | final Fragment f2 = new TrivialFragment(); | |
30 | final Bundle b2=new Bundle(); | |
31 | b2.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_details_tab); | |
32 | f2.setArguments(b2); | |
33 | ||
34 | final Fragment f3 = new TrivialFragment(); | |
35 | final Bundle b3=new Bundle(); | |
36 | b3.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_other_tab); | |
37 | f3.setArguments(b3); | |
6d7e08bf PT |
38 | |
39 | t1.setTabListener(new AddEventTabListener(f1)); | |
40 | t2.setTabListener(new AddEventTabListener(f2)); | |
41 | t3.setTabListener(new AddEventTabListener(f3)); | |
42 | ||
43 | actionBar.addTab(t1); | |
44 | actionBar.addTab(t2); | |
45 | actionBar.addTab(t3); | |
46 | } | |
47 | ||
48 | @Override | |
49 | public boolean onCreateOptionsMenu(final Menu menu) { | |
50 | final MenuInflater inflater = getMenuInflater(); | |
51 | inflater.inflate(R.menu.add_event, menu); | |
52 | return true; | |
53 | } | |
54 | ||
55 | @Override | |
56 | public boolean onOptionsItemSelected(final MenuItem item) { | |
57 | switch (item.getItemId()) { | |
58 | case R.id.cancel: | |
59 | finish(); | |
60 | return true; | |
61 | default: | |
62 | return false; | |
63 | } | |
5cf4714f | 64 | } |
e6ba41a8 PT |
65 | |
66 | public void showTimePickerDialog(View v) { | |
67 | if(v.getId()==R.id.date_start || v.getId()==R.id.date_end) { | |
68 | DialogFragment newFragment = new DatePickerFragment(); | |
69 | newFragment.show(getFragmentManager(),"datePicker"); | |
70 | } | |
71 | else { | |
72 | DialogFragment newFragment = new TimePickerFragment(); | |
73 | newFragment.show(getFragmentManager(), "timePicker"); | |
74 | } | |
75 | } | |
5cf4714f | 76 | } |