I am learning Java programming for Android Apps. I am currently working with an app that has 4 input fields which I would like to validate as a percentage total. I understand how this works and can do this in HTML where you can validate between 0 and 100 using a 0 < i < 100 but what i do not understand in Java is how i will execute this - I have search for a few ways to do this but I do not get this. I am asking for help and not someone to code it for me. I also need to output a message if you enter a number wrongly (which I can successfully do in my app - but I am struggle with the validation of the data entered by the user at this stage)
Asked
Active
Viewed 64 times
-1
-
2`if (0 < i && i < 100) { System.out.println("Wrong number: " + i); }` – Andreas Jan 18 '16 at 06:31
-
you probably should learn **programming** first before you hop onto mobile device development ... start with Hello-World apps in Java on your local machine. Everything else might lead to confusion and the failure of your project. – specializt Jan 18 '16 at 06:34
1 Answers
0
You ca check the input at this way:
if(Interger.valueOf(myinput.getText().toString()) > 0)
and let the user known:
Toask.makeText(getapplicationContext(), "Your message here", Toast.LONG).show();

Andreas Schmidt
- 154
- 6