Skip to content

CustomViewDialog

Philipp Niedermayer edited this page Mar 4, 2017 · 13 revisions

Dialogs with custom views

extends SimpleDialog

Extend this class to create a dialog with a custom view.

Inflate view

protected abstract View onCreateContentView(Bundle savedInstanceState)

Inflate, setup and return your custom view here.
For inflating, use one of the provided inflate(...) functions to make sure custom theme attributes are applied correctly.

Providing results

protected Bundle onResult(int which)

Overwrite this method to return a Bundle that will be merged into the results returned by OnDialogResultListener.onResult.

Various

protected void onDialogShown()

Overwrite this method to take action once the dialog is shown such as settings the initial state of the positive button (see below) or an input focus.

protected boolean acceptsPositiveButtonPress()

Overwrite and return false from this function if you don't want the dialog to be closed yet, for example due to an invalid user input.

protected void pressPositiveButton()

Simulates a positive button press e.g. due to an IME action.

protected void setPositiveButtonEnabled(boolean enabled)

Updates the positive button state.

Clone this wiki locally