Fixed
Status Update
Comments
de...@gmail.com <de...@gmail.com> #3
What's the workaround for this?
li...@gmail.com <li...@gmail.com> #4
Postpone your reference until after the dialog is shown,
this is my workaround (a little more expensive).
final AlertDialog d = new AlertDialog.Builder(this)...create();
//final Button b1 = d.getButton(Dialog.BUTTON_POSITIVE);
editName.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable ed) {
Button b1 = d.getButton(Dialog.BUTTON_POSITIVE); //TODO #6360 bug
b1.setEnabled(ed.length() > 0);
...
this is my workaround (a little more expensive).
final AlertDialog d = new AlertDialog.Builder(this)...create();
//final Button b1 = d.getButton(Dialog.BUTTON_POSITIVE);
editName.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable ed) {
Button b1 = d.getButton(Dialog.BUTTON_POSITIVE); //TODO #6360 bug
b1.setEnabled(ed.length() > 0);
...
de...@gmail.com <de...@gmail.com> #5
Ah, then I wasn't too off. I did the disabling in onPrepareDialog.
jo...@gmail.com <jo...@gmail.com> #6
Bug exists in Gingerbread as well.
ve...@gmail.com <ve...@gmail.com> #7
jonas, you've gotta be kidding me (!)
aa...@gmail.com <aa...@gmail.com> #8
[Comment deleted]
pa...@gmail.com <pa...@gmail.com> #9
I hate AlertDialog class.
be...@gmail.com <be...@gmail.com> #10
I hate it too
I wanted to get buttons and give them typeface objects to place on them my custom font.
bad bad bad
I wanted to get buttons and give them typeface objects to place on them my custom font.
bad bad bad
ex...@gmail.com <ex...@gmail.com> #11
This problem still exists.
See the attach picture, I'm using FroYo(2.2).
Please fix it.
See the attach picture, I'm using FroYo(2.2).
Please fix it.
da...@gmail.com <da...@gmail.com> #12
There is a simple workaround (simpler than adding the addTextChangedListener).
Do the enable/disable buttons after the create() in a OnShowListener:
//dialog creation
dialog....create();
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
//enable/disable buttons
...
}
});
This works. (At least for me)
Do the enable/disable buttons after the create() in a OnShowListener:
//dialog creation
dialog....create();
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
//enable/disable buttons
...
}
});
This works. (At least for me)
tw...@gmail.com <tw...@gmail.com> #13
There isn't work because dialog is not DialogInterface. It is AlertDialog
tw...@gmail.com <tw...@gmail.com> #14
You should get your buttons after you call dialog.show() method
da...@gmail.com <da...@gmail.com> #15
//@two2: This is working for me. By the way, the setOnShowListener is a level 8 API (FroYo)
//...
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
((AlertDialog)dialog).getButton(AlertDialog.BUTTON_POSITIVE).setFocusable(true);
}
});
dialog.show();
//...
//...
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
((AlertDialog)dialog).getButton(AlertDialog.BUTTON_POSITIVE).setFocusable(true);
}
});
dialog.show();
//...
an...@provisio.com <an...@provisio.com> #16
bug still existent in 3.1
al...@gmail.com <al...@gmail.com> #17
1) As you can see here:
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.1_r2/com/android/internal/app/AlertController.java#AlertController.getButton%28int%29
mButtonPositiveMessage must not be NULL.
2) mButtonPositiveMessage initializations is here:
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.1_r2/com/android/internal/app/AlertController.java#AlertController.setButton%28int%2Cjava.lang.CharSequence%2Candroid.content.DialogInterface.OnClickListener%2Candroid.os.Message%29
3) Final hint:
DialogInterface.OnClickListener listener — must not be NULL
mButtonPositiveMessage must not be NULL.
2) mButtonPositiveMessage initializations is here:
3) Final hint:
DialogInterface.OnClickListener listener — must not be NULL
da...@gmail.com <da...@gmail.com> #18
Still there on 4.0. Whee!
ch...@gmail.com <ch...@gmail.com> #19
Thank you Alex,
The setting the clickListeners fixed it for me.
Cheers!
The setting the clickListeners fixed it for me.
Cheers!
ov...@gmail.com <ov...@gmail.com> #20
still here on 4.1. nice.
getting the buttons in onShowListener as described above works for me, on 2.3 and 4.1 .
getting the buttons in onShowListener as described above works for me, on 2.3 and 4.1 .
go...@schildbach.de <go...@schildbach.de> #21
I found out that if you're using activity managed dialogs, you can in onCreateDialog(int code) use an AlertDialog.Builder to create your dialog and in onPrepareDialog(Dialog dialog) use ((AlertDialog) dialog).getButton() to mess around with the buttons.
dw...@sharpmind.de <dw...@sharpmind.de> #22
I also struggled with this one as I wanted to expand the number of text lines on the button (it seems this is hardcoded to 2, regardless of the size of the text). Comment 21 works: You can't do this in onCreateDialog() because the views don't actually exist yet, but you can do this in onPrepareDialog().
li...@gmail.com <li...@gmail.com> #23
4.4 and it's still here
gg...@gmail.com <gg...@gmail.com> #24
cr...@supercomputo.mx <cr...@supercomputo.mx> #25
It still there,
Android API 30
Android API 30
Description
But I got null at following code.
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setPositiveButton(android.R.string.ok, listener);
AlertDialog dialog = builder.create();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setFocusable(true);
dialog.show();
or
..................
dialog.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setFocusable(true);