tags:

views:

42

answers:

1

Hi! I am writing a custom component (derived from a relative layout) which has to show a dialog, Is there a way to do this using callbacks like oncreatedialog or onpreparedialog?

if not: if i have to create the dialog outside oncreatedialog, i have to "attach it to an Activity with setOwnerActivity(Activity)". How can the custom component access the activity it is used in, when it is used in the activity's xml-layout and not created from code?

A: 

Just use the context you were given on construction.

new AlertDialog.Builder(getContext())
.setTitle("Title")
.setMessage("Message")
.create()
.show();
CaseyB