<requestFocus />
</EditText>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/repeat"
- android:layout_weight="1"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <Switch
- android:id="@+id/repeat_switch"
- android:layout_weight="1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
</LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/repeat_layout"
- android:orientation="vertical" >
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="left" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/repeat_every"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <EditText
- android:id="@+id/repeat_time"
- android:inputType="number"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <Spinner
- android:id="@+id/repeat_spinner"
- android:entries="@array/repeat_array_p"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- />
-
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/repeat_count_layout"
- android:layout_gravity="left"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
-
- <Spinner
- android:id="@+id/repeat_type"
- android:entries="@array/repeat_type_array"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1" />
- <EditText
- android:id="@+id/repeat_count"
- android:inputType="number"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="gone" />
- <TextView
- style="@android:style/Widget.DeviceDefault.EditText"
- android:id="@+id/repeat_until"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="showDateTimePickerDialog"
- android:ems="8"
- android:visibility="gone" />
- </LinearLayout>
- </LinearLayout>
</LinearLayout>
</ScrollView>
public final class AddEventActivity extends Activity implements OnDateSetListener, OnTimeSetListener{
- private class OnCheckedChangeListener implements android.widget.CompoundButton.OnCheckedChangeListener{
- private final LinearLayout layout;
- public OnCheckedChangeListener(final LinearLayout layout){
- this.layout=layout;
- }
-
- private class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{
- private final View repeatCount;
- private final View repeatUntil;
-
- public OnItemSelectedListener(final View repeatCount, final View repeatUntil) {
- this.repeatCount=repeatCount;
- this.repeatUntil=repeatUntil;
- }
-
- @Override
- public void onItemSelected(final AdapterView<?> whatever, final View ignored, final int pos, final long id) {
- switch(pos){
- case 0:
- repeatCount.setVisibility(View.GONE);
- repeatUntil.setVisibility(View.GONE);
- break;
- case 1:
- repeatCount.setVisibility(View.GONE);
- repeatUntil.setVisibility(View.VISIBLE);
- break;
- case 2:
- repeatCount.setVisibility(View.VISIBLE);
- repeatUntil.setVisibility(View.GONE);
- break;
- default:
- }
- }
-
- @Override public void onNothingSelected(final AdapterView<?> arg0) { /* do nothing */ }
- }
-
- @Override
- public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
- if(isChecked) {
- Utils.setEnabledRecursively(layout, true);
- final Spinner repeatType = (Spinner) findViewById(R.id.repeat_type);
- repeatType.setOnItemSelectedListener(new OnItemSelectedListener(findViewById(R.id.repeat_count),findViewById(R.id.repeat_until)));
- }else {
- Utils.setEnabledRecursively(layout, false);
- }
- }
- }
-
private TextView dateTimeTextView;
public static final String EXTRA_EVENT = "event";
private static Event event=new Event();
final ActionBar actionBar = getActionBar();
setContentView(R.layout.add_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));
-
final EditText title = (EditText) findViewById(R.id.eventtitle);
title.requestFocus();
title.setText(event.title);
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){
+ if(v.getId()==R.id.date_start || v.getId()==R.id.date_end ){
final String[] parts = dateTimeTextView.getText().toString().split("-");
final DatePickerFragment fragment = new DatePickerFragment();
final Bundle args = new Bundle();
}
public static String formatDate(final int year, final int month, final int day){
- return String.format(Locale.ENGLISH, "%4d-%02d-%02d", year, month, day);
+ return String.format(Locale.ENGLISH, "%4d-%02d-%02d", year, month+1, day);
}
public static void addAlarm(final Application application, final long time, final long eventId) throws SQLException{