Hi,
if you have static final String DRINK_TYPE you can use follow construct
if(className.DRINK_TYPE.equals("beer")){
}
or make new class just with constats
class IConstants
...
public static final String DRINK_TYPE = "type";
public static final String BEER = "beer";
public static final String LAGER = "lager";
...
and next
if(IConstants.DRINK_TYPE.equals(IConstants.BEER)){
...
}
2009/5/10 Kevin J. Brooks <[email protected]>:
>
> I am trying to pass a simple string in to a new activity. I feel a
> little dense. I have looked at the samples, and I just can't seem to
> get it through my thick head. What do I need in the first parameter.
>
> public static final String DRINK_TYPE = "type";
> .
> .
> .
> Intent i = new Intent(this, BeerScreen.class);
> i.putExtra(DRINK_TYPE, "beer");
>
>
> Then in BeerScreen.java
>
> String sType = extras.getString("type");
> if(sType == "beer"){
>
> The code inside the if is not executed. <sigh>
>
> Kevin
>
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---