Я планирую дать создать 3 кнопки с layout_weight = 1, не заинтересованы в настраиваемом диалоге. Так что я написал ниже код. Он не работает. Всегда кнопка да дает мне ноль.
Что не так в этом коде?
AlertDialog dialog= new AlertDialog.Builder(this).create();
dialog.setIcon(R.drawable.alert_icon);
dialog.setTitle("title");
dialog.setMessage("Message");
dialog.setButton(AlertDialog.BUTTON_POSITIVE,"Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
}
});
Button yesButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
Log.w("Button",""+yesButton);//here getting null
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1f);
yesButton.setLayoutParams(layoutParams);
dialog.show();
С уважением,
Разработчик Android.