<string name="friday">Friday</string>
<string name="saturday">Saturday</string>
<string name="save">Save</string>
- <string name="addevtab1">Basic info</string>
+ <string name="addevtab1">Basic</string>
<string name="addevtab2">Details</string>
<string name="addevtab3">Other</string>
<string name="eventname">Event Name</string>
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
-import android.widget.DatePicker;
-import android.widget.EditText;
-import android.widget.TextView;
-import android.widget.TimePicker;
+import android.widget.*;
public final class AddEventActivity extends Activity implements OnDateSetListener, OnTimeSetListener{
private TextView dateTimeTextView;
+ private Event tempEvent=new Event();
@Override
protected void onCreate(final Bundle savedInstanceState) {
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));
+ t1.setTabListener(new AddEventTabListener(f1,tempEvent,0));
+ t2.setTabListener(new AddEventTabListener(f2,tempEvent,1));
+ t3.setTabListener(new AddEventTabListener(f3,tempEvent,2));
actionBar.addTab(t1);
actionBar.addTab(t2);
finish();
return true;
case R.id.save:
- Event e = getEvent(this);
+ //TODO Save event
+ Toast toast = Toast.makeText(getApplicationContext(),"Event saved!",Toast.LENGTH_LONG);
+ toast.show();
+ finish();
return true;
default:
return false;
}
}
- private Event getEvent(final Activity v) {
- //TODO get all information
- final long _id=23;//blatul olimpic
- final String organizer="";
- final String title="";
- final String eventLocation="";
- final String description="";
- final int eventColor=0;
- final long dtstart=0;
- final long dtend=0;
- final long calendarID = 0;
- System.out.print(title + description);
- Event ret = new Event(_id,organizer,title,eventLocation,description,eventColor,dtstart,dtend,calendarID);
- return ret;
- }
-
public void showDateTimePickerDialog(final View v) {
dateTimeTextView=(TextView) v;
if(v.getId()==R.id.date_start || v.getId()==R.id.date_end || v.getId() == R.id.repeat_until)
public class AddEventTabListener implements ActionBar.TabListener {
public Fragment fragment;
+ private Event ev;
+ int tabId;
- public AddEventTabListener(final Fragment fragment) {
+ public AddEventTabListener(final Fragment fragment,Event e,int tabId) {
this.fragment = fragment;
+ this.ev = e;
+ this.tabId=tabId;
}
@Override
@Override
public void onTabUnselected(final Tab tab, final FragmentTransaction ft) {
+ switch (tabId) {
+ case 0:
+ ev.title=fragment.getView().findViewById(R.id.eventtitle).toString();
+ break;
+ case 1:
+ ev.description=fragment.getView().findViewById(R.id.description).toString();
+ break;
+ case 2:
+ break;
+ }
ft.remove(fragment);
}