Hello there if you are using adapter there might be a chance.
All you need to know when you used any dialog in adapter,getContext(),context or activity won't work sometime.
Here is the trick I used
v.getRootView().getContext()
where v is the view object you are referencing.
Eg.
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new DatePickerDialog(v.getRootView().getContext(), date, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
});
If you are getting this problem because of alert dialog.
Refer [here][1] But it is same concept.
[1]: https://stackoverflow.com/questions/6367771/displaying-alertdialog-inside-a-custom-listadapter-class