android - Do not close dialog windows till told otherwise? -
In a dialog window, the user searches for a search keyword. So the database looks for it and returns the list of items. If the size of the lists is 0, then I would like to inform the user that nothing was found and the dialogue window opened until the user with more than 0 results or until the user decides to exit the dialog window, the right keyword To enter.
If no results were found in DB, then I could not understand the way to open the window. Help would be appreciated:
public discourse onCreateDialog (bundle saved Instansstet) {AlertDialog.Builder builder = new AlertDialog.Builder (getActivity ()); Last edit text input = new edit text (getActivity ()); Input.setHint ("enter keyword"); Builder.setTitle ("search"). setview (input) .setPositiveButton ( "full", the new DialogInterface.OnClickListener () {public void onClick (DialogInterface communicate Int whichButton) {newExams = database.searchList (input.getText (). Tostring ()); if (newExams.size () == 0} Make text (GetActivity), "Nothing!", Toast.LNGTH_LONG) .show (); Return; // Here, I want to make sure that the window is one of the inputting keywords efforts will be opened} ExamAdapter newAdapter = new ExamAdapter (getActivity (), newExams); listViewExams.setAdapter (newAdapter);}}) .setNegativeButton ( "Cancel", new DialogInterface.OnClickListener () clamps on {public void Do that (Dialogue Interface Dialog, Inc., Jebton) {// Canceled}}}); Return builder.cent (); }
Create a custom dialog piece and override your button, is an example of my work old code:
public class MyAlertDialogFragment DialogFragment {public static MyAlertDialogFragment newInstance (int title) {MyAlertDialogFragment frag = new MyAlertDialogFragment () extends; Bundle args = new bundle (); Args.putInt ("title", title); Frag.setArguments (args); Return Return; } @ Override Public Dialog on Critical Dialect (InstantStatus Saved from Bundles) {int title = getArguments (). GetInt ("title"); See final view = getActivity (). GetLayoutInflater (). Flowers (R.layout.dialoglayout, null); ) (GetActivity ()) // .setIcon (R.drawable.icon) .setTitle (title) .setView (View) .setPositiveButton (getActivity () return new AlertDialog.Builder. GetResources (. GetString (R.string.dialog_save) new DialogInterface.OnClickListener () {public void onClick (DialogInterface communicate, Int Jebtn) {// something bad ();}}) .setNegativeButton (getActivity (). GetResources (). GetString (R.string.dialog_cancel), new DialogInterface.OnClickListener () {public void onClick (DialogInterface communicate, integer whichButton) {// do something}}) .setNeutralButton (getActivity (). getResources (). GetString (R.string.dialog_cl ear), new DialogInterface.OnClickListener ( ) {Click Public Zero (DialogInterface Dialog, Int Jabunton) {}}). Create ();} @ Override Public Wide OnStart () is {super.nstart (); // super.onstart (), where dialog.show () is actually called // on the built-in dialogue, After // should be AlertDialog d = (AlertDialog) getDialog (); If (d! = Null) {button neutralbutton = (button) d.getbutton (Dialog.BUTTON_NEUTRAL); // neutralbutton.setbackgroundResource (R.drawable.xloginbutton); // neutralButton.setTextColor (Color Similar Color ("#FFFFF")); NeutralButtonksetOnClickListener (New View.OnClickListener () {@Override see public void onClick (v) {boolean wantToCloseDialog = the false; // stuff, the truth may set wantToCloseDialog to do ... if (wantToCloseDialog) {dismissed ( );} // other dialogue is open. Make sure that you have clearly communicate enable to cancel // to stop specifically if you //.}}); }}}
Comments
Post a Comment