import android.app.ActionBar.Tab;
import android.app.Fragment;
import android.app.FragmentTransaction;
+import android.util.Log;
import android.widget.EditText;
import android.widget.TextView;
@Override
public void onTabSelected(final Tab tab, final FragmentTransaction ft) {
- if(isAdded)
- ft.attach(fragment);
- else {
- isAdded = true;
- ft.add(android.R.id.content, fragment);
- }
+ ft.replace(android.R.id.content, fragment, null);
}
@Override
public void onTabUnselected(final Tab tab, final FragmentTransaction ft) {
switch (tabId) {
case 0:
- ev.title=fragment.getView().findViewById(R.id.eventtitle).toString();
- String start=fragment.getView().findViewById(R.id.date_start).toString()+ " " +
- fragment.getView().findViewById(R.id.time_start).toString();
- String end=fragment.getView().findViewById(R.id.date_end).toString()+ " " +
- fragment.getView().findViewById(R.id.time_end).toString();
+ ev.title=((TextView)fragment.getView().findViewById(R.id.eventtitle)).getText().toString();
+ String start=((TextView)fragment.getView().findViewById(R.id.date_start)).getText()+ " " +
+ ((TextView)fragment.getView().findViewById(R.id.time_start)).getText();
+ String end=((TextView)fragment.getView().findViewById(R.id.date_end)).getText()+ " " +
+ ((TextView)fragment.getView().findViewById(R.id.time_end)).getText();
try {
Date s=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(start);
Date e=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(end);
case 2:
break;
}
- ft.detach(fragment);
}
@Override
import java.util.Date;
public final class TrivialFragment extends Fragment {
- Event ev;
- public static final String ARGUMENT_EVENT= "Event";
-
- @Override
- public void onActivityCreated (Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- ev=getArguments().getParcelable(ARGUMENT_EVENT);
- switch (getArguments().getInt(ARGUMENT_LAYOUT)) {
- case R.layout.add_event_basic_tab:
- EditText title = (EditText) getView().findViewById(R.id.eventtitle);
- title.setText(ev.title, TextView.BufferType.EDITABLE);
-
- TextView tstart = (TextView) getView().findViewById(R.id.time_start);
- TextView tend = (TextView) getView().findViewById(R.id.time_end);
- SimpleDateFormat sf=new SimpleDateFormat("HH:MM");
- Date d=new Date(ev.dtstart);
- tstart.setText(sf.format(d).toString(),TextView.BufferType.NORMAL);
- d.setTime(ev.dtend);
- tend.setText(sf.format(d).toString(),TextView.BufferType.NORMAL);
-
- SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
- TextView dstart = (TextView)getView().findViewById(R.id.date_start);
- TextView dend = (TextView)getView().findViewById(R.id.date_end);
- d.setTime(ev.dtstart);
- dstart.setText(sd.format(d).toString(),TextView.BufferType.NORMAL);
- d.setTime(ev.dtend);
- dend.setText(sd.format(d).toString(),TextView.BufferType.NORMAL);
- break;
- case R.layout.add_event_details_tab:
- EditText description = (EditText) getView().findViewById(R.id.description);
- description.setText(ev.description,TextView.BufferType.EDITABLE);
- break;
- case R.layout.add_event_other_tab:
- break;
- }
-
- }
-
private static class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{
private final View repeatCount;
private final View repeatUntil;
}
}
- public static final String ARGUMENT_LAYOUT="layout";
+ public static final String ARGUMENT_EVENT = "Event";
+ public static final String ARGUMENT_LAYOUT = "layout";
+ private Event ev;
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
-
final View view=inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false);
- final LinearLayout layout = (LinearLayout) view.findViewById(R.id.repeat_layout);
-
- if(layout != null){
- final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch);
- Utils.setEnabledRecursively(layout, false);
+
+ ev=getArguments().getParcelable(ARGUMENT_EVENT);
+ switch (getArguments().getInt(ARGUMENT_LAYOUT)) {
+ case R.layout.add_event_basic_tab:
+ final LinearLayout layout = (LinearLayout) view.findViewById(R.id.repeat_layout);
+ final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch);
+ Utils.setEnabledRecursively(layout, false);
- repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener(layout, view));
- }
+ repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener(layout, view));
+
+ EditText title = (EditText) view.findViewById(R.id.eventtitle);
+ title.setText(ev.title);
+
+ TextView tstart = (TextView) view.findViewById(R.id.time_start);
+ TextView tend = (TextView) view.findViewById(R.id.time_end);
+ SimpleDateFormat sf=new SimpleDateFormat("HH:MM");
+ Date d=new Date(ev.dtstart);
+ tstart.setText(sf.format(d).toString());
+ d.setTime(ev.dtend);
+ tend.setText(sf.format(d).toString());
+
+ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
+ TextView dstart = (TextView)view.findViewById(R.id.date_start);
+ TextView dend = (TextView)view.findViewById(R.id.date_end);
+ d.setTime(ev.dtstart);
+ dstart.setText(sd.format(d).toString());
+ d.setTime(ev.dtend);
+ dend.setText(sd.format(d).toString());
+ break;
+ case R.layout.add_event_details_tab:
+ EditText description = (EditText) view.findViewById(R.id.description);
+ description.setText(ev.description);
+ break;
+ case R.layout.add_event_other_tab:
+ break;
+ }
return view;
}
}