final AlertDialog dlg = new AlertDialog.Builder(LoginActivity.this).create();
dlg.show();
Window window = dlg.getWindow();
if(window!=null){
window.setContentView(R.layout.other_devices);
TextView text = (TextView) window.findViewById(R.id.ok);
text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dlg.cancel();
}
});
}
转载于:https://www.cnblogs.com/hui413027075/p/6654500.html