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