I am having trouble with passing the date from the calendar to another activity. It’s not the current date that I wanted to show, it’s the date that the user selects on the calendar that I have coded.
Below are my codes.
@Override
public void onClick(View view)
{
String date_month_year = (String)view.getTag();
selectedDayMonthYearButton.setText(new StringBuilder().append("Selected:").append(date_month_year));
Intent k = new Intent(Calendar_Event.this, Create_Events.class);
startActivity(k);
try
{
Date parsedDate = dateFormatter.parse(date_month_year);
Log.d(tag, "Parsed Date: " + parsedDate.toString());
}
catch(ParseException e)
{
e.printStackTrace();
}
}
public int getCurrentDayOfMonth()
{
return currentDayOfMonth;
}
private void setCurrentDayOfMonth(int currentDayOfMonth)
{
this.currentDayOfMonth = currentDayOfMonth;
}
public void setCurrentWeekDay(int currentWeekDay)
{
this.currentWeekDay = currentWeekDay;
}
public int getCurrentWeekDay()
{
return currentWeekDay;
}
}//end GridCellAdapter
I trying to pass the date selected onClick to the next activity that this class is linked to.
Any help will be greatly appreciated, Thanks you!
use
Intent.putExtra(String date)for passing date from one activity to another Activity. Change your Button Click Code as in Calendar_Event.class:In Calendar_Event Activity :
In Create_Events Activity :