我试过并搜索过这些东西,但没有得到答案
我正在点击一个关于点击的视图现在我想要解除膨胀的视图,但它没有发生 这是我的来源......
icon1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater inflater = (LayoutInflater)screen.getSystemService(screen.LAYOUT_INFLATER_SERVICE);
layout = inflater.inflate(R.layout.image_popup,null);
AlertDialog.Builder builder = new AlertDialog.Builder(Actvity.this);
builder.setCancelable(true);
builder.setView(layout);
我不想添加正面或负面按钮
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
final AlertDialog alertDialog = builder.create();
alertDialog.setIcon(R.drawable.icon1);
alertDialog.show();
}
});
答案 0 :(得分:8)
使用自定义对话框并使用此方法达到您的要求dialog.setCanceledOnTouchOutside(true);
示例强>
public void getCustomOkDialog(Context mContext) {
final Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.ok_dialog);
dialog.setCanceledOnTouchOutside(true);
TextView txtMessage = (TextView) dialog.findViewById(R.id.txtMessage);
txtMessage.setText("Your Message");
dialog.show();
}