Issue
I created an activity which is show google map on the screen, and consists of 3 option menus to interact with user selection.
When user press on the sub menu I want to show pop-up input dialog box that user can enter date(dd/mm/yyyy) or pop-up date picker. I will use that date to query the location which kept at that date then mark on the map.
My problem is when I tried to created input dialog or whatever inside my sub menu, nothing show on screen except map view. I think it may have something special to do like this. So, I searched for many days, but still do not get an answer.
Any one have an idea or did this ? Please, suggest me. This is my first time with google map. Appreciate every answer.
Solution
Your problem is not specifically with the MapActivity. I have an app that has this feature (a MapActivity subclass that shows a date picker) and haven't had any problems. I suspect the issue lies with how you are showing your date picker. Perhaps try it in an plain activity (ie one that doesn't derive from MapActivity) to confirm this.
So in your class that extends the MapActivity you will need something like:
// the id for your dialog
static final int DATE_DIALOG_ID = 0;
// the date from the picker
Date mDate;
// so you are defining a member variable mDateSetListener which implements
// onDateSet. This gets called when the user selects a date.
private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
Calendar cal = GregorianCalendar.getInstance();
cal.set (year, monthOfYear, dayOfMonth);
// store the date that was picked
mDate = cal.getTime();
// update your map
// ...
}
};
@Override
protected android.app.Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(this,
mDateSetListener,
year, month, day);
}
return null;
}
@Override public boolean onMenuItemSelected(int featureId, MenuItem item)
{
switch(item.getItemId())
{
// handle your date selection menu item
case R.id.date:
showDialog(DATE_DIALOG_ID);
break;
}
}
Answered By - RedBlueThing
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.