I have the following code which creates an event when a button is clicked. I would like to know how to create more than one, (Say 5) events by pressing this button. Thank you for any help!
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Button button = (Button)findViewById(R.id.button1);
// button.setOnClickListener(this);
final CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox1);
final CheckBox checkBox2 = (CheckBox) findViewById(R.id.checkBox2);
final Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
if (checkBox.isChecked()) {
{
SimpleDateFormat formatter = new SimpleDateFormat("MMMM dd, yyyy, h:mmaa");
long lnsTime = 0, lneTime = 0;
Date dateObject;
try{
String dob_var = "August 16, 2012, 11:35PM";
dateObject = formatter.parse(dob_var);
lnsTime = dateObject.getTime();
Log.e(null, Long.toString(lnsTime));
dob_var = "August 16, 2012, 11:59PM";
dateObject = formatter.parse(dob_var);
lneTime = dateObject.getTime();
Log.e(null, Long.toString(lneTime));
}
catch (java.text.ParseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
Log.i("E11111111111", e.toString());
}
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("title", "9:00AM Start");
intent.putExtra("description", "There will be a 9:00AM start tomorrow.");
intent.putExtra("eventLocation", "Chris' house");
intent.putExtra("beginTime", lnsTime);
intent.putExtra("endTime", lneTime);
startActivity(intent);
}
}
The code creates the single event just fine so far, its just I need multiple to be created, preferably without the "save/cancel" screen.