下面的方法在 doInBackground 方法中运行时崩溃,但在活动中运行良好。
private void showPopup(ArrayList<String> dates) {
ListPopupWindow popup = new ListPopupWindow(context);
popup.setAdapter(new ArrayAdapter<String>(context,
android.R.layout.simple_list_item_1, dates
.toArray(new String[dates.size()])));
popup.setAnchorView(context.periodicTable);
popup.setWidth(ListPopupWindow.WRAP_CONTENT);
popup.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(context, "Clicked item " + position,
Toast.LENGTH_SHORT).show();
context.startProgressDialog();
}
});
popup.show();
}