Edit event. work in progress[3]
authorPetru <l3asketballplayer@yahoo.com>
Tue, 13 Aug 2013 12:01:52 +0000 (15:01 +0300)
committerPetru <l3asketballplayer@yahoo.com>
Tue, 13 Aug 2013 12:01:52 +0000 (15:01 +0300)
Text fields now fill with event data.

src/ro/ieval/unical/AddEventActivity.java
src/ro/ieval/unical/AddEventTabListener.java
src/ro/ieval/unical/TrivialFragment.java

index bf4a8bb1f0c13a408c91867fd12d1c32bc58e1b0..0bc8691e8e33a1f08ac1f8fb5643bcaf60f2ac9d 100644 (file)
@@ -40,17 +40,17 @@ public final class AddEventActivity extends Activity implements OnDateSetListene
                final ActionBar.Tab t2 = actionBar.newTab().setText(this.getString(R.string.addevtab2));
                final ActionBar.Tab t3 = actionBar.newTab().setText(this.getString(R.string.addevtab3));
 
-               f1 = new TrivialFragment();
+               f1 = new TrivialFragment(tempEvent);
                final Bundle b1=new Bundle();
                b1.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_basic_tab);
                f1.setArguments(b1);
 
-               f2 = new TrivialFragment();
+               f2 = new TrivialFragment(tempEvent);
                final Bundle b2=new Bundle();
                b2.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_details_tab);
                f2.setArguments(b2);
 
-               f3 = new TrivialFragment();
+               f3 = new TrivialFragment(tempEvent);
                final Bundle b3=new Bundle();
                b3.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_other_tab);
                f3.setArguments(b3);
index 2a89db7be39f276105a7522b33d93b67d78c3ddf..e9b840f2927bff57ead35b411887e3e39653b321 100644 (file)
@@ -31,13 +31,6 @@ public class AddEventTabListener implements ActionBar.TabListener {
                        isAdded = true;
                        ft.add(android.R.id.content, fragment);
                }
-
-        switch (tabId) {
-            case 0:
-                //EditText title =(EditText) fragment.getView().findViewById(R.id.eventtitle);
-                //title.setText(ev.title, TextView.BufferType.EDITABLE);
-                break;
-        }
        }
 
        @Override
index e578abf05c107ca76a2a9371c5cbb87501d0f2a2..54c9731d675ae6de5d3cc3b4de845829b7c5523e 100644 (file)
@@ -7,13 +7,51 @@ import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.CompoundButton;
-import android.widget.LinearLayout;
-import android.widget.Spinner;
-import android.widget.Switch;
+import android.widget.*;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 public final class TrivialFragment extends Fragment {
+    Event ev;
+    public TrivialFragment(Event e) {
+        ev=e;
+    }
+
+    @Override
+    public void onActivityCreated (Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        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;
This page took 0.012217 seconds and 4 git commands to generate.