Tôi hiện đang thực hiện một ứng dụng Android có chứa hộp thoại cảnh báo tùy chỉnh. Nó chứa một nút, nhưng tôi không thể đặt lề cho nút. mã được đưa ra dưới đây. phương pháp setmargin không được làm việcLàm cách nào để đặt ký tự động trong Android?
AlertDialog.Builder myDialog = new AlertDialog.Builder(Login.this);
Button button = new Button(Login.this);
button.setText("Send");
LayoutParams buttonLayoutParams
= new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
button.setLayoutParams(buttonLayoutParams);
resetPassword=editText.getText().toString();
LinearLayout layout = new LinearLayout(Login.this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(textView);
layout.addView(editText);
layout.addView(button);
myDialog.setView(layout);
nó không hoạt động. nút bên trong alertdialog – user1057197
Vui lòng xem Câu trả lời đã chỉnh sửa của tôi, nó đang hoạt động cho tôi. –
không, nó không hoạt động. nó cho thấy một lỗi thêm cast vào buttonlayoutparams trong phương thức setMargin. – user1057197