3

is it possible to bring up a dialog box in android after every certain value (provided by the user). In my app, the user can go up and go down value by 1 by pressing a button and what I want to do is allow the user to set a number e.g. 45 and after every 45 numbers the user goes up or down by, I want a dialog box to show up.

For example, if the user want to see a dialog box after every 100 value then there would type in 100 in a textbox and start pressing the up and down button and when they value reaches the current value + 100 / - 100 then a dialog box will appear. For instance, after if the user has set the dialog box to appear after every 100 value then the dialog box will appear on numbers like 100, 200, 300 etc.

3 Answers3

3
 if((your_value%100) == 0)
    // doing your stuff 
    else 
    // doing your stuff 
Mikey
  • 687
  • 4
  • 17
0

call a dialoguebox in your button method. In your 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();
Flat Eric
  • 7,971
  • 9
  • 36
  • 45
Cr. 7
  • 1
0

Here is the Algo which i suppose you should implement

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

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

enter image description here

enter image description here

Jamil
  • 5,457
  • 4
  • 26
  • 29
  • Accepted, sadly I can't vote up because I need 15 rep, 1 more to go :) –  Dec 19 '14 at 17:31
  • thanks :) I have 1 more question if you don't mind answering. Is it possible to change the font size to be bigger in the dialog box –  Dec 19 '14 at 17:38
  • i think you can use custom dialog box in android to alter the font,size,color and add more views like image edittext etc. here is the link http://www.androidapplicationdevelopment.guru/2014/06/custom-dialog-box-in-android-with-example.html – Jamil Dec 19 '14 at 17:42
  • http://stackoverflow.com/questions/13341560/how-to-create-a-custom-dialog-box-in-android – Jamil Dec 19 '14 at 17:43