简体   繁体   中英

Text Field Commands (Android) (Java)

I am trying to create a text field command in my Android Studio project. I have a text field and when I type a keyword some code will run. So a 'else if statement'

I have created this in Objective-C for a iOS project earlier. Here is the code from their

-(void) perform: (NSString *) command {
    // WithOut WhiteSpace (Text Control)
    if([command caseInsensitiveCompare:@"ROTATE"] == NSOrderedSame) // Command Rotate
    {
        [pattern decreaseAngle];
        int f = [pattern getAngle];
        [self changeAngle:(f)];
    }

Now, i need to do the same-thing but in java for my Android App. How can i create a else-if statement in Java for a text field?

Syntax for if else in java is :

if (strcmp(string1, string2) == 0) {
// Do something.
}
else{
// Do something else
}

See JAVA String functions like strcmp which are used to compare strings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM