This is a Java mistake that is common. By "common" I mean "one I make
all the frickin time." You should use String.equals() instead, like

    if (!codedate.equals("220809")) {

If you just use the != operator then the JVM will compare the string
pointer addresses, not their values.



Yusuf Saib
Android
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.



On Aug 21, 5:00 am, GlennovitS <[email protected]> wrote:
> Hey everybody..
>
> I'm just startet writing code for android.. And then I need to have
> some if-sentences.. (sorry for my english) they look like this
>
> @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>
>         Date dateDate = new Date();
>         String codedate = new SimpleDateFormat("ddMMyy").format
> (dateDate);
>
>         if (codedate != "220809") {txtKommentar.setText
> (R.string.k220809);}
>         if (codedate != "210809") {txtKommentar.setText
> (R.string.k210809);}
>         if (codedate != "200809") {txtKommentar.setText
> (R.string.k200809);}
>         if (codedate != "190809") {txtKommentar.setText
> (R.string.k190809);}
>
> }
>
> and if the 'codedate' has a value of '210809', it still does this:...
>
> txtKommentar.setText(R.string.k190809);
>
> ...like the 'codedate'-strings value was 190809.. what is wrong?.
>
> please help me.. i can't figure it out..
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to