Andreas,
If you only need to pass one number parameter, you could include it in
the ID.
protected Dialog onCreateDialog (int id) {
int realId = id & 0xffff;
int numFiles = id >> 16;
.....
}
You will want to call removeDialog (int id) as soon as the dialog is
dismissed, to avoid building up a multitude of dialogs that only differ
by the number of files.
BTW, in my little app I just use dialog builder like this:
AlertDialog.Builder builder = new AlertDialog.Builder(this); // "this"
is Activity
builder.setMessage(....);
AlertDialog alert = builder.create();
alert.show();
without using onCreateDialog and friends.
Don't know if this is the right way to do it, but I haven't seen
anything in logcat about leaked windows.
-- Kostya
05.08.2010 12:42, livinberlin пишет:
Thanks for your responses!
The problem is not to set the message of the dialog, but how to pass
my customized message string to onCreateDialog or onPrepareDialog.
Both functions only have a single int parameter (dialog id). When
calling showDialog(..), I just can send a single dialog id, and not
more parameters such as a customized message string.
For example, consider an alert dialog that shows the number of files
in a folder. The message could be "Number of files: 15" or "Number of
files: 21". How can I pass this message string over to onCreateDialog
or onPrepareDialog? With API level 8, showDialog is extended by a
Bundle parameter, which could be uses to pass such information.
A solution would be to store my message string in a member variable of
the activity before calling showDialog, and reading that member
variable in onCreateDialog/onPrepareDialog. But this could cause
problems when calling showDialog multipe times, because onCreateDialog/
onPrepareDialog are called asynchronously.
Sorry if I didn't make the problem clear in my first message. Any more
hints?
Thanks,
Andreas
--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en