Sign Up

How to use editText().getText() in if else statment in android studio.

Posted Apr 29, 2017 by Sunil Bhagwat

  1. Sunil Bhagwat

    Sunil Bhagwat Member Scrap Metal

    Messages:
    1
    Likes Received:
    0
    Devices:
    coolpad 3600I
    Dear all

    I am new and student of android studio. I want use editText().getText() in if else statement in my application. Below are the codes and I am not knowing how to use it.
    I want to show that
    if ((editText().getText() <=18) && (editText().getText() >=34)){
    }else if
    ((editText().getText() <=35) && (editText().getText() >=54)){
    }

    how to make statement using <=, or && and >= operators.
     
  2. Akash Jain

    Akash Jain Well-Known Member Sentient Droid HAL

    Messages:
    3,651
    Likes Received:
    768
    Devices:
    HTC Butterfly 2, Vido M9i (Dual Boot)
    What are you actually trying to do and what's wrong with the code you posted?
     
  3. Dev Lt

    Dev Lt Member Drone Droid

    Messages:
    12
    Likes Received:
    3
    Devices:
    LG g3
    All you need to do is to convert the value to String by invoking toString() method. Just replace editText().getText(); to editText().getText().toString();
    and instead of plain numbers use them in quotation marks ("18" not 18)
     

Share This Page