Show dialog after every defined android value

is it possible to open a dialog in android after every certain value (provided by the user). In my application, the user can go up and down by 1 by clicking a button and what I want to do is let the user set a number for example. 45 and after every 45 numbers the user goes up or down, I want a dialog to appear.

For example, if the user wants to see a dialog after every 100 values, then 100 characters will be entered in the text box and the up and down buttons will be pressed, and when they reach the current value + 100 / - 100, the dialog will pop up. For example, after the user sets the dialog to appear after every 100 values, then a dialog will appear with numbers like 100, 200, 300, etc.

+3


source to share


3 answers


 if((your_value%100) == 0)
    // doing your stuff 
    else 
    // doing your stuff 

      



+3


source


call the dialog in the buttons method. In the button method ...



AlertDialog alertDialog1 = new AlertDialog.Builder(
            AlertDialogActivity.this).create();

// Setting Dialog Title
alertDialog1.setTitle("Alert Dialog");

// Setting Dialog Message
alertDialog1.setMessage(String.valueOf(your_number_variable));

// Showing Alert Message
alertDialog1.show();

      

0


source


Here is the Algo I believe you should implement

 if((incremented_value%100) == 0)
    { show dialog box and reset variable} 
    else 
    { keep counting }

      

if the remainder is 0, it means that the incremented_value is divisible by 100, and that means that you have reached 100

enter image description here

enter image description here

0


source







All Articles