Reputation: 492
In my preferences I have a ListPreference which opens DialogPreference. Now I would like to create a simple dialog without Cancel button and title Category. I want just the list of options, which I would like to make custom too. I already looked at the source code and I'm a bit confused because do I have to write my own dialog preference class just to remove title and cancel button? Or I can just extend DialogPreference to create all the customizations? There are also some widgetLayout/dialogLayout attributes, but I don't see an option how to remove a title/cancel button from there. Or should I extend ListPreference? Any suggestions would be greatly appreciated, because I'm running out of ideas. dialog
Upvotes: 2
Views: 6160
Reputation: 492
I managed to solve my problem with title and cancel button. Here is the solution:
public class PreferenceDialog extends ListPreference {
public PreferenceDialog(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
super.onPrepareDialogBuilder(builder); //To change body of overridden methods use File | Settings | File Templates.
builder.setNegativeButton(null,null);
builder.setTitle(null);
}
}
I just had to pass null values and it worked like a charm.
Upvotes: 11