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 Moderator Sentient Droid HAL

    Messages:
    3,660
    Likes Received:
    778
    Devices:
    HTC Butterfly 2
    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:
    13
    Likes Received:
    5
    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