android - DialogPreference shouldn't close if no option selected -
I have a DialogPreference and I when "right", "to avoid the user from turning off by pressing Cancel" Edit: Edit: Whenever I have made a dialogue, then try to reach the right button to disable it. But I could not make it: (
to make a tweak where define a custom dialog be your own button (right click and off) to Czech out to handle your preference onClick I have not tested this code, just informing you that you can do to solve it! The dialog remains open until you call dialog.dismiss; In that case you have to make your drop-down menu, choice or whatever you want to display in your layout file. After pressing or canceling, you should know that the user has made a choice, and parses that choice in his own preferences. (Check the link given above) Taking RGDS
implements public square YourClass OnClickListener {private button DialogButton ;. private dialog dialogue; public void onCreate (Bundle savedInstanceState) {super .onCreate (savedInstanceState); setContentView (R.layout.MainLayout); / * your code ... * / DialogButton = (button) findViewById (R.id.DialogButtonId); DialogButton.setOnClickListener (this);} public void onCli ck (View v) {switch (v. getId ()) {case R.id.DialogButtonId: LayoutInflater inflater = LayoutInflater.from (YourClass.this); final scene inflay = inflater.inflate (R.layout.DialogLayout, (ViewGroup ) FindViewById (R.id.RootIdOfDialogLayout); TextView YourTextView = (text view) inflay.findViewById (R.id.TextViewId); Cancel Button = (button) inflay.findViewById (RIDCalButtonID); cancel.setOnClickListener (YourClass. This); Button OK = (Button) inflay.findViewById (RIDOKBUTONID); Ok.setOnClickListener (YourClass.this); Dialog = new dialog (YourClass.this); Dialog.setContentView (inflay); Dialog.setTitle (GetString (R.string.TitleStringId)); Dialog.show (); break; Case R.id.CancelButtonId: / * Check if the user has selected an option, then true call dialog.dismiss () * / break; Case R.id.OkButtonId: / * Checking your preferences here (eg putString (string key, string value)) * / / * Checking the user has chosen an option, then true call dialog.dismiss () * / break; }}}
Comments
Post a Comment