Android - Change the text of the positive button of an AlertDialog?

One solution is just to force the button to redraw. For example, a button to cancel a lengthy operation might change to 'OK' on complete, e.g.

One solution is just to force the button to redraw. For example, a button to cancel a lengthy operation might change to 'OK' on complete, e.g. Button button = progressDialog. GetButton(ProgressDialog.

BUTTON1); button. SetText("OK"); button.invalidate().

Thanks. Works like a charm. – Sudar Dec 3 '10 at 6:00.

This works for me @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ID: return AlertDialog. Builder(this). SetTitle(R.string.

Contact_groups_add) . SetView(addView). SetPositiveButton(R.string.

Ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }). SetNegativeButton(R.string. Cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }).create(); } return null; }.

– Sudar Jul 27 '10 at 10:46 In none of them. I don't reused those methods of the activity. This code simply shows an alert dialog with the view from addView (inflated prior).

– Pentium10 Jul 27 '10 at 10:56 I understand this code. But my question was different. I already use onCreateDialog() and onPrepareDialog() functions.

I created the dialog in the onCreateDilaog() method but when I try to change the text of the positive button in the onPrepareDialog() it is only changing the onClickListener and not the text. – Sudar Jul 27 '10 at 11:28 You can easily adapt my example to your needs. Just call .create(); instead of show() and return in your onCreateDialog method the Dialog created by the code.

– Pentium10 Jul 27 '10 at 12:59 My onCreateDialog() code works properly without any issues. My problem is that, when I try to change the text of the positive button in the onPrepareDialog() using the setButton() method, the text is not changed. The reason why I am doing it in onPreapareDialog() is that onCreateDialog() will be called only once when the dialog is created for the first time.

I want to reuse the same dialog, but only change the text of the positive button from "Add" to "Edit". When I set the text using the setButton method, it is not getting changed. – Sudar Jul 27 '10 at 16:55.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions