Thursday, December 15, 2011

[android-developers] Re: if() Statement Not Working Correctly...

Wow... I feel pretty stupid right now...
Thanks haha...
Long Night xD

On Dec 15, 11:20 pm, Kristopher Micinski <krismicin...@gmail.com>
wrote:
> Pick up a Java book... :-)...
>
> you can't compare strings with == in java...  use .equals()...
>
> kris
>
>
>
>
>
>
>
> On Thu, Dec 15, 2011 at 11:17 PM, Matt Clark <mrclark32...@gmail.com> wrote:
> > I am currently writing an application to easily retrieve the bus
> > schedule for my school. I have a series of intents and content views
> > that get information from the user such as
> > Bus From
> > Bus To
> > Day
>
> > The variables are passed to a final intent, where depending on what
> > the user has selected it will choose the correct contentview to show
> > the user the schedule. The problem that i am having is that i am
> > getting a string of say 'equine' and checking it in an if statement to
> > see if the sting is indeed 'equine'. The program is skipping right
> > over it as if the statement was false, even while debugging. The
> > segment in question is below.
>
> > locationFrom = getIntent().getExtras().getString("From");
> > locationTo = getIntent().getExtras().getString("To");
> > locationDay = getIntent().getExtras().getString("Day");
>
> > if (locationFrom == "equine") {
> >        if (locationTo == "equine") {
> >                //None
> >        } else if (locationTo == "gaebe") {
> >                if (locationDay == "monday" || locationDay == "tuesday"
> >                                || locationDay == "wednesday"
> >                                || locationDay == "thursday") {
> >                        setContentView(R.layout.equine_gaebe_week);
> >                } else if (locationDay == "friday") {
> >                        setContentView(R.layout.equine_gaebe_friday);
> >                } else if (locationDay == "saturday") {
> >                        setContentView(R.layout.equine_gaebe_saturday);
> >                } else if (locationDay == "sunday") {
> >                        setContentView(R.layout.equine_gaebe_sunday);
> >                }
> >        }
> > }else{
> >        Log.e("ERROR!", locationFrom);
> > }
>
> > When looking in the LogCat i get:
> > 12-15 23:10:15.034: ERROR/ERROR!(11489): equine
>
> > This is frustrating me as I have no idea what the problem is.... Any
> > and all help is greatly appreciated...
> > ~Matt
>
> > --
> > 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+unsubscribe@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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment