M9A
M9A

Reputation: 3286

How to check if a TextView contains a certain string

Hi I want to add an if statement that checks to see if a text in a textview (called TextView1) contains a ".". I know I can check to see if the text equals ".". But I dont know how to check if the text contains a ".". Can anyone help me with this? Thanks

I dont know what to do to TextArea1 to check if it contains a decimal point

if (TextArea1      ){
    //Do Something
}

Upvotes: 9

Views: 12798

Answers (2)

Thiago
Thiago

Reputation: 13302

For String you can just to the following:

String text = "Z Hello";

if(text.contains("Z"){
 // Yes
} 

Upvotes: 0

Eng.Fouad
Eng.Fouad

Reputation: 117665

if(TextArea1.getText().toString().contains("."))

Upvotes: 19

Related Questions