- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
- final ActionBar.Tab t1 = actionBar.newTab().setText(this.getString(R.string.addevtab1));
- final ActionBar.Tab t2 = actionBar.newTab().setText(this.getString(R.string.addevtab2));
- final ActionBar.Tab t3 = actionBar.newTab().setText(this.getString(R.string.addevtab3));
-
- final Fragment f1 = new TrivialFragment();
- final Bundle b1=new Bundle();
- b1.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_basic_tab);
- f1.setArguments(b1);
-
- final Fragment f2 = new TrivialFragment();
- final Bundle b2=new Bundle();
- b2.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_details_tab);
- f2.setArguments(b2);
-
- final Fragment f3 = new TrivialFragment();
- final Bundle b3=new Bundle();
- b3.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_other_tab);
- f3.setArguments(b3);
-
- t1.setTabListener(new AddEventTabListener(f1));
- t2.setTabListener(new AddEventTabListener(f2));
- t3.setTabListener(new AddEventTabListener(f3));
-
- actionBar.addTab(t1);
- actionBar.addTab(t2);
- actionBar.addTab(t3);
-
- handleViews(f1,f2,f3);
-
- }
-
- private void handleViews(Fragment f1,Fragment f2,Fragment f3) {
- Switch repeatSwitch = (Switch) this.getFragmentManager().findFragmentById(f1.getId()).getView().findViewById(R.id.repeat_switch);
- final Spinner repeatSpinner = (Spinner) this.getFragmentManager().findFragmentById(f1.getId()).getView().findViewById(R.id.repeat_spinner);
- repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
-
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if(isChecked) {
- repeatSpinner.setEnabled(true);
- }else {
- repeatSpinner.setEnabled(false);
- }
- }
- });
+ setContentView(R.layout.add_event);
+
+ if(getIntent().hasExtra(EXTRA_EVENT)) {
+ final LinearLayout layout = (LinearLayout) findViewById(R.id.repeat_layout);
+ final Switch repeatSwitch = (Switch) findViewById(R.id.repeat_switch);
+ Utils.setEnabledRecursively(layout, false);
+
+ repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener(layout));
+
+ EditText title = (EditText) findViewById(R.id.eventtitle);
+ title.setText(event.title);
+
+ TextView tstart = (TextView) findViewById(R.id.time_start);
+ TextView tend = (TextView) findViewById(R.id.time_end);
+ SimpleDateFormat sf=new SimpleDateFormat("HH:mm");
+ Date d=new Date(event.dtstart);
+ tstart.setText(sf.format(d).toString());
+ d.setTime(event.dtend);
+ tend.setText(sf.format(d).toString());
+
+ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
+ TextView dstart = (TextView)findViewById(R.id.date_start);
+ TextView dend = (TextView)findViewById(R.id.date_end);
+ d.setTime(event.dtstart);
+ dstart.setText(sd.format(d).toString());
+ d.setTime(event.dtend);
+ dend.setText(sd.format(d).toString());
+ EditText description = (EditText) findViewById(R.id.description);
+ description.setText(event.description);
+ }