Android Question Text.Contains

tufanv

Expert
Licensed User
Longtime User
Hello,

I want to checkif text1.text.cotains only numbers ( there wont be any charachter different than a number ) is it possible to do it with text.contains ?

ty
 

KMatle

Expert
Licensed User
Longtime User
text1.contains checks if a string is found in text1.

If it's an edittext just Change the input_type to numbers so the user can only Input numbers (or decimal numbers if you like).

Otherwise do a loop and check the characters in that string with isNumber
 
Upvote 0

Descartex

Well-Known Member
Licensed User
Longtime User
Upvote 0

tufanv

Expert
Licensed User
Longtime User
text1.contains checks if a string is found in text1.

If it's an edittext just Change the input_type to numbers so the user can only Input numbers (or decimal numbers if you like).

Otherwise do a loop and check the characters in that string with isNumber
my users can enter numbers or strings into textfiled. I dont want to limit them to numbers only. I want to do stg if there are only numbers and do another thing if not. Maybe i can use the loop example. ty
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
text1.contains checks if a string is found in text1.

If it's an edittext just Change the input_type to numbers so the user can only Input numbers (or decimal numbers if you like).

Otherwise do a loop and check the characters in that string with isNumber
isnumber(text1.text) works for me . Thanks !
 
Upvote 0
Top