By using .equals on a String rather than ==...

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------


On Sat, Jan 23, 2010 at 12:38 PM, ProGirl <[email protected]> wrote:

> Ok :) how did u fix the problem ?
>
> On Nov 25 2009, 10:14 pm, balanagu sabareesh <[email protected]>
> wrote:
> > Thank you for your reply. finally i got it.
> >
> > On Tue, Nov 24, 2009 at 10:25 PM, Justin Anderson
> > <[email protected]>wrote:
> >
> > > if(str == "First") --------------> BAD
> > > if(str.equals("Second")) ---> GOOD
> >
> > > That being said, the typical android way would be to create another
> > > activity and launch it when you click the item in the list view.  Have
> you
> > > tried doing that instead?
> >
> > > ----------------------------------------------------------------------
> > > There are only 10 types of people in the world...
> > > Those who know binary and those who don't.
> > > ----------------------------------------------------------------------
> >
> > > On Mon, Nov 23, 2009 at 8:15 AM, sabs <[email protected]> wrote:
> >
> > >> Hi
> > >> I created the list successfully but my problem is when ever i select
> > >> an item in the list it is not moving to another layout. In that layout
> > >> i created a button and text view. can any one help me
> > >> below iam placing my code.
> >
> > >> //In this code wheneven i select the second option from the list it
> > >> has to go to another layout where one text view will be there.
> >
> > >> public class SList extends ListActivity implements
> > >> OnItemClickListener
> > >> {
> >
> > >>        final String[] items = new String[]{
> > >>                "First","Second"
> > >>        };
> > >>    ListView lv = null;
> > >>    public void onCreate(Bundle savedInstanceState)
> > >>    {
> > >>        super.onCreate(savedInstanceState);
> > >>       setListAdapter(new ArrayAdapter<String>(this,
> > >>                        android.R.layout.simple_list_item_1,items));
> > >>       lv = getListView();
> > >>       lv.setChoiceMode(lv.CHOICE_MODE_SINGLE);
> > >>        lv.setTextFilterEnabled(true);
> > >>        lv.setOnItemClickListener(this);
> >
> > >>    }
> >
> > >>    /*protected void onListItemClick(ListView l, View v, int position,
> > >> long id)
> > >>    {
> >
> > >>        super.onListItemClick(l, v, position, id);
> > >>        int pos = position;
> > >>        String str = (String) lv.getItemAtPosition(pos);
> > >>        if(str == "First")
> > >>        {
> > >>                setContentView(R.layout.second);
> >
> > >>        }
> >
> > >>    }*/
> >
> > >> public void onItemClick(AdapterView parent, View v, int postion, long
> > >> id) throws NullPointerException
> > >>        {
> > >>                int pos = postion;
> > >>                String str = (String)lv.getItemAtPosition(pos);
> > >>                if(str.equals("Second"))
> > >>                {
> > >>                        setContentView(R.layout.main);
> > >>                        TextView tv = null;
> > >>                        tv = (TextView)findViewById(R.id.TextView01);
> > >>                        tv.setText("Hello");
> > >>                        setContentView(tv);
> >
> > >>                }
> > >> }
> >
> > >> //In this code wheneven i select the second option it has to go to
> > >> another layout where one text view will be there.
> >
> > >> please help me
> >
> > >> --
> > >> 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]<android-beginners%[email protected]>
> <android-beginners%[email protected]<android-beginners%[email protected]>
> >
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/android-beginners?hl=en
> >
> > >  --
> > > 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]<android-beginners%[email protected]>
> <android-beginners%[email protected]<android-beginners%[email protected]>
> >
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-beginners?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]<android-beginners%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

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