| 1 | package ro.ieval.unical; |
| 2 | import android.app.ActionBar; |
| 3 | import android.app.Activity; |
| 4 | import android.app.Fragment; |
| 5 | import android.os.Bundle; |
| 6 | import android.view.Menu; |
| 7 | import android.view.MenuInflater; |
| 8 | import android.view.MenuItem; |
| 9 | |
| 10 | public final class AddEventActivity extends Activity { |
| 11 | @Override |
| 12 | protected void onCreate(final Bundle savedInstanceState) { |
| 13 | super.onCreate(savedInstanceState); |
| 14 | setContentView(R.layout.add_event); |
| 15 | setTitle(R.string.addeventtitle); |
| 16 | final ActionBar actionBar = getActionBar(); |
| 17 | actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); |
| 18 | final ActionBar.Tab t1 = actionBar.newTab().setText(this.getString(R.string.addevtab1)); |
| 19 | final ActionBar.Tab t2 = actionBar.newTab().setText(this.getString(R.string.addevtab2)); |
| 20 | final ActionBar.Tab t3 = actionBar.newTab().setText(this.getString(R.string.addevtab3)); |
| 21 | |
| 22 | final Fragment f1 = new TrivialFragment(R.layout.add_event_basic_tab); |
| 23 | final Fragment f2 = new TrivialFragment(R.layout.add_event_details_tab); |
| 24 | final Fragment f3 = new TrivialFragment(R.layout.add_event_other_tab); |
| 25 | |
| 26 | t1.setTabListener(new AddEventTabListener(f1)); |
| 27 | t2.setTabListener(new AddEventTabListener(f2)); |
| 28 | t3.setTabListener(new AddEventTabListener(f3)); |
| 29 | |
| 30 | actionBar.addTab(t1); |
| 31 | actionBar.addTab(t2); |
| 32 | actionBar.addTab(t3); |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public boolean onCreateOptionsMenu(final Menu menu) { |
| 37 | final MenuInflater inflater = getMenuInflater(); |
| 38 | inflater.inflate(R.menu.add_event, menu); |
| 39 | return true; |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public boolean onOptionsItemSelected(final MenuItem item) { |
| 44 | switch (item.getItemId()) { |
| 45 | case R.id.cancel: |
| 46 | finish(); |
| 47 | return true; |
| 48 | default: |
| 49 | return false; |
| 50 | } |
| 51 | } |
| 52 | } |