android - Hide default buttons in DialogPreference -
I currently have a custom dialog class that extends DialogPreference (which is definitely part of a PreferenceScreen).
In this dialog there are custom buttons that save and cancel, so I would like to get rid of the standard "positive" and "negative" buttons.
AlertDialog tried using the getButton method but no success.
in your XML instead of the DialoguePropference:
Priority Android: Title = "This works as a button" Android: Key = "Button" Android: Summary = "It can act as a button to create its own dialog" /> Then in Java:
preference button = (priority) searchpress ("button"); Button .setOnPreferenceClickListener (new Preference.OnPreferenceClickListener () {@Override Public boolean onPreferenceClick (priority arg0) {showDialog (MY_DIALOG); // Assume MY_DIALOG 'final int MY_DIALOG = 1;' Class false false;} The body}); Then add to your class body:
@Override Safe Dialogue onCreateDialog {int {ID} {case SHOW_APP_STRING: LayoutInflater inflater = (LayoutInflator) getSystemService (References LAOUT_INFLATER_SERVICE); See mylayout = inflater.inflate (R. late.layout, empty); Final AlertDialog myDialog = New AlertDialog Builder (this) .setview (mileage). Show (); // buttons are below the dialog so that you can close the dialog within your button listeners save button = (button) myLayout.findViewById (R.id.save); Cancel button = (button) myLayout.findViewById (R.id.cancel); //ClickClickLists; return myDialog for both of your buttons; }} I'm not sure this is the best way, but how do I do it, and it works.
Comments
Post a Comment