On Fri, May 10, 2013 at 4:59 AM, Jefferson Delgado Pérez <[email protected]
> wrote:
> I've been looking for a while and I have not managed to figure out how to
> make a protected Dialog onCreateDialog (int id), which can be accessed from
> several activities by id sent by ShowDialog (id)
>
> With public void Dialog onCreateDialog (int id) enough I guess, but the
> problem is, that according to the user to choose one option or another, you
> must go to an activity or another, and that's the part that I can not
> implement or understand how should.
>
> For example, if striking B will accept me, and if I click cancel I go to C.
> Right now I have repeated onCreateDialog protected Dialog (int id) in each
> activity and managing their own dialogue, something I think that nothing is
> efficient.
>
> Any idea where to get the shots?
>
If I understood your question correctly, something like this.
public class DialogFactory
{
public static int DIALOG_USED_BY_A_LOT_OF_ACTIVITIES_ID = 0;
....
public Dialog getDialogUsedByALotOfActivities(Activity activity)
{
// Create and return dialog with activity context;
}
}
public class OneActivityThatUsesDialog extends Activity
{
private void showDialogUsedByALotOfActivities()
{
showDialog(DialogFactory.DIALOG_USED_BY_A_LOT_OF_ACTIVITIES_ID);
}
protected Dialog onCreateDialog(int id)
{
if (id == DialogFactory.DIALOG_USED_BY_A_LOT_OF_ACTIVITIES_ID)
return DialogFactory.getDialogUsedByALotOfActivities(this);
}
}
It's not the prettiest solution, but Dialogs have always been one of the
worse parts of Android.
Also look at DialogFragment, they might have improved things with the
newest android version.
-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices
--
--
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
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.