Clean up and go back to replace instead of add/attach/detach
[unical.git] / src / ro / ieval / unical / AddEventTabListener.java
index e9b840f2927bff57ead35b411887e3e39653b321..9238d4c03a4679156a36162e9288d42c0f34ee0f 100644 (file)
@@ -4,6 +4,7 @@ import android.app.ActionBar;
 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;
 
@@ -25,23 +26,18 @@ public class AddEventTabListener implements ActionBar.TabListener {
 
        @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);
@@ -58,7 +54,6 @@ public class AddEventTabListener implements ActionBar.TabListener {
             case 2:
                 break;
         }
-               ft.detach(fragment);
        }
 
        @Override
This page took 0.01125 seconds and 4 git commands to generate.