What about this?

string PleaseEnter  = (EditText)FindViewById(R.id.PleaseEnter).getText();

if(PleaseEnter.equals("1")){
tv.setText(PleaseEnter);
}else if(PleaseEnter.equals("2")){
tv.setText(PleaseEnter);
}

-----Original Message-----
From: android-developers@googlegroups.com
[mailto:android-developers@googlegroups.com] On Behalf Of Ma
Sent: Thursday, February 23, 2012 2:44 PM
To: Android Developers
Subject: [android-developers] If statement help and text displaying on the
screen

I ran my code and in eclipse in the log it is showing under text the output
as what my else statement is set to. I do not see this text on the screen. I
am trying to compare a number to a number in my if statement. I have stated
PleaseEnter as android:inputType="number" in the layout. I have included
some of the ways that I have tried to change my if statement to compare the
values. I need help with 1. Having if statement validated to show what it
needs to and 2. Have the output show on the screen.

try
PleaseEnter=(EditText)findViewById(R.id.PleaseEnter); {

  if ("1".equals(PleaseEnter))
  //(PleaseEnter.getText().equals("1"))
  //(PleaseEnter.equals("1"))
  {
    //   tv.setText("This is the display 1");
      System.out.println("This is 1");
    }
else if  (PleaseEnter.equals("2"))
    System.out.println("This 2");
else if  (PleaseEnter.equals("3"))
    System.out.println("This 3");
  else
     System.out.println("That number is not recognized.");
  }}
  catch (Exception ex)

--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to