我已经卡了2天,终于放弃了。我需要你在日历功能方面的帮助。该人选择产品(在按钮上)并设置消息并允许他们在可以重新订购时添加提醒。现在我让它打开日历,但无法让日历根据该产品设置日期。我不确定如何设置字符串值、调用它并设置日历日期。我知道这是基本的东西,但我感谢您的帮助!对不起,冗长的代码。我想确保我包含了所有相关的内容。
这是我的代码:
Button reorder1 = (Button) findViewById(R.id.rotramadol);
Button reorder2 = (Button) findViewById(R.id.roaciphex);
Button reorder3 = (Button) findViewById(R.id.roflexeril);
reorder1.setOnClickListener(this);
reorder2.setOnClickListener(this);
reorder3.setOnClickListener(this);
@Override
public void onClick(View v) {
if (v.getId() == R.id.rotramadol) {
//this one needs the calendar set 10 days from now
AlertDialog ad = new AlertDialog.Builder(this)
.setMessage(
"Order Quantity 90 tabs requires 10 days")
.setTitle("Tramadol")
.setPositiveButton("Set Reminder", this)
.setNegativeButton("OK", this).setCancelable(false)
.create();
ad.show();
} else if (v.getId() == R.id.roaciphex) {
//this one needs the calendar set 25 days from now
AlertDialog ad1 = new AlertDialog.Builder(this)
.setMessage("Order Quantity 30 tabs requires 25 days")
.setTitle("Aciphex")
.setPositiveButton("Set Reminder", this)
.setNegativeButton("OK", this).setCancelable(false)
.create();
ad1.show();
} else if (v.getId() == R.id.roflexeril) {
//this one needs the calendar set 7 days from now
AlertDialog ad2 = new AlertDialog.Builder(this)
.setMessage("Order Quantity 30 tabs requires 7 days")
.setTitle("Flexeril")
.setPositiveButton("Set Reminder", this)
.setNegativeButton("OK", this).setCancelable(false)
.create();
ad2.show();
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
switch (which) {
case DialogInterface.BUTTON_POSITIVE: // yes
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra(Events.TITLE, "Reorder");
intent.putExtra(Events.EVENT_LOCATION, "");
intent.putExtra(Events.DESCRIPTION,
"https://www.place they reorder.com");
GregorianCalendar calDate = new GregorianCalendar();
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
calDate.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
calDate.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);
intent.putExtra(Events.RRULE, "FREQ=DAILY;COUNT=1;");
intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);
startActivity(intent);
break;
case DialogInterface.BUTTON_NEGATIVE: // no
dialog.cancel();
break;
default:
break;
}
}