first off, use String.equals() to compare the contents of strings, not ==. the == operator checks for object reference equality. this isn't what you want, unless you use intern() throughout, which i wouldn't recommend.


Hi,
The basic list that I want to view is working.

In my first list activity(ListDemoActivity), I choosed some element, which triggers another list A activity. If I go back (on pressing "BACK" key), the state of ListDemoActivity screen is preserved. Now If I select the same element again, I expect the state of A activity to be preserved aswell, but its not happening.

Below is the code snippet, Can you please suggest me what I need to do?

public class ListDemoActivity extends ListActivity {
    String[] firstPage = {"a", "b", "c", "d", "e"};
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
setListAdapter(new ArrayAdapter<String>(this,
                        android.R.layout.simple_list_item_1,
                        firstPage));
} public void onListItemClick(ListView parent, View v,
                                int position, long id)
    {
        String txt = firstPage[position];
        if ((txt == "a") ||
            (txt == "b"))
{ Intent startActivity = new Intent(this, Activity_A.class);
            startActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startActivity); }
        else
{ Intent startActivity = new Intent(this, Activity_B.class);
            startActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startActivity); } }
}

On Tue, Jan 26, 2010 at 5:28 PM, theSmith <<mailto:chris.smith...@gmail.com>chris.smith...@gmail.com> wrote:


On Jan 25, 11:48 pm, android beginner <<mailto:android.beginne...@gmail.com>android.beginne...@gmail.com>
wrote:

 > so, each sub-lists should be created as list activity. On selecting any
 item, should call that particular list activity. Is my understanding
 correct?

Yes


 Also, how to store parent list in the stack? so that on pressing "escape"
 key, I can navigate backwards.

Android does this automatically, and I assume you mean the 'back'
key.  Each new activity is launched ontop of the older ones allowing
you to navigate backwards down the stack.

-theSmith



 Thanks

On Tue, Jan 26, 2010 at 9:11 AM, saad bouchehboun <<mailto:bsaad1...@gmail.com>bsaad1...@gmail.com>wrote:

 >
 > your item must be a listactivity , when you add it to your parent
 > list , the UI is adapted automaticly .

> On 25 jan, 06:24, android beginner <<mailto:android.beginne...@gmail.com>android.beginne...@gmail.com>
 > wrote:
 > >  Hi,

 > > My Activity has list of items and on clicking any item, new window with
 > > different set of list has to appear and this can continue upto 4 or 5
 > level
 > > depths. I need your expert advice on how to achieve this.

 > > Can I have each sub-list to be of separate activity? If there are any
 > online
 > > examples matching this requirement, please let me know.

 > > Thank

 > --
 > You received this message because you are subscribed to the Google
 > Groups "Android Developers" group.
> To post to this group, send email to <mailto:android-developers@googlegroups.com>android-developers@googlegroups.com
 > To unsubscribe from this group, send email to

> > <mailto:android-developers%2bunsubscr...@googlegroups.com>android-developers+unsubscr...@googlegroups.com<<mailto:android-developers%252bunsubscr...@googlegroups.com>android-developers%2bunsubscr...@googlegroups.com>

 > > For more options, visit this group at
 
><http://groups.google.com/group/android-developers?hl=en>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 <mailto:android-developers@googlegroups.com>android-developers@googlegroups.com
To unsubscribe from this group, send email to
<mailto:android-developers%2bunsubscr...@googlegroups.com>android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/android-developers?hl=en>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>http://groups.google.com/group/android-developers?hl=en


--
jason.vp.engineering.particle

--
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