Android 自定义dialog

以下是简易dialog,需要自己写layout界面,很实用。

final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
View view = activity.getLayoutInflater().inflate(R.layout.love_dialog_guest_grid_layout, null,false);
Button btnOk = (Button) view.findViewById(R.id.love_btn_ok);
btnOk.setText(R.string.love_diglog_up);
btnOk.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        dialog.dismiss();

    }
});
Button btnCancel = (Button) view.findViewById(R.id.love_btn_cancel);
btnCancel.setText(R.string.love_diglog_up);
btnCancel.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        dialog.dismiss();
    }
});

dialog.setContentView(view);
dialog.show();

你可能感兴趣的:(Android应用层)