我已经在同一个应用程序的不同活动中使用了下面的代码,没有任何问题,但是在此活动中,单击图像时会得到一个关闭的力量。事件处理程序会在我看到吐司时触发,如果我不调用popupImage()。在调试器中,我得到一个类抛出异常,但我不知道如何解决它。Android AlertDialog force关闭
picture.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Show popup with full image of the clicked small img.
Toast.makeText(getApplicationContext(), "debug CLICKED IMG",
Toast.LENGTH_LONG).show();
popupImage(show);//fungerer stadig ikke
}
});
}
和
private void popupImage(Show show) {
Context context = getApplicationContext();
// ImgHandler imageHandler = new ImgHandler();
// Bitmap bitmapImage = imageHandler.getImg(show.getShowId()) ;
AlertDialog.Builder imageDialog = new AlertDialog.Builder(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_fullimage_dialog, (ViewGroup) ((Activity) context).findViewById(R.id.layout_root));
ImageView image = (ImageView) layout.findViewById(R.id.fullimage);
image.setImageBitmap(pic);
imageDialog.setView(layout);
imageDialog.setPositiveButton(getString(R.string.Close),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
imageDialog.create();
imageDialog.show();
}
请提供确切的错误信息,并指出提高了'ClassCastException'的准确代码行。 – CommonsWare