改装原生的dialog
改装 dialog 定制
View rootView = LayoutInflater.from(mContext).
inflate(R.layout.nfc_tag_name_dialog, null, false);
final EditText etTagName = (EditText) rootView.findViewById(R.id.et_nfctag_name);
String datetime = DateUtils.currentTimeStringNew().replaceAll(":","-");
etTagName.setText(datetime);
etTagName.setSelection(etTagName.getText().length()); //光标位置
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(getString(R.string.tag_dialog_name));
builder.setView(rootView);
builder.setPositiveButton(R.string.action_ok, null
);
builder.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
final AlertDialog alertDialog = builder.create();
alertDialog.show();
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener();