Well, that you will have to decide. If there can be multiple selections,
then I would expect a button called "Done" which the user has to press when
he is done selecting.


Kumar Bibek
http://techdroid.kbeanie.com
http://www.kbeanie.com



On Thu, Dec 23, 2010 at 8:41 AM, pramod.deore <[email protected]>wrote:

> Hello, from where should I call finish(). And how I know that user has
> finished selecting list items.
>
> On Dec 22, 3:58 pm, "pramod.deore" <[email protected]> wrote:
> > In my list view there are checkboxes and  suppose user want to select
> > multiple items if suppose he select 3 items then? Is that mean code
> > execute between activities 3 times?
> >
> > On Dec 22, 3:54 pm, Kumar Bibek <[email protected]> wrote:
> >
> > > If you are using a list view, then try onItemClickListener.
> >
> > > Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com
> >
> > > On Wed, Dec 22, 2010 at 4:23 PM, pramod.deore <
> [email protected]>wrote:
> >
> > > > Hey Bibek Thanks.
> > > > > Try this. On a specific event, set the result and just call finish.
> That
> > > > > should do.
> >
> > > > But on what event I call finish? Because here I am just selecting
> > > > items from list. And how should I know that user had finished there
> > > > selection?
> >
> > > > On Dec 22, 3:47 pm, Kumar Bibek <[email protected]> wrote:
> > > > > YEah,
> >
> > > > > Why are you calling finish from onPause method?  It will finish you
> > > > > application, even when you would not want it to.
> >
> > > > > Try this. On a specific event, set the result and just call finish.
> That
> > > > > should do.
> >
> > > > > Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com
> >
> > > > > On Wed, Dec 22, 2010 at 4:14 PM, pramod.deore <
> [email protected]
> > > > >wrote:
> >
> > > > > > Hi I have one activity which invoked another activity
> >
> > > > > > roomIntent.putExtra("roomName",roomNM );
> > > > > > roomIntent.setClass(AddScheduler.this,RoomList.class);
> > > > > > startActivityForResult(roomIntent,Room_SELECT);
> >
> > > > > > protected void start(Intent intent)
> > > > > >        {
> > > > > >                this.startActivityForResult(intent,Room_SELECT);
> > > > > >        }
> >
> > > > > >        protected void onActivityResult(int requestCode, int
> resultCode,
> > > > > > Intent data)
> > > > > >        {
> > > > > >                System.out.println (requestCode);
> >
> > > > > >                switch(requestCode)
> > > > > >                {
> > > > > >                        case Room_SELECT:
> >
> > > > > >                                System.out.println (resultCode);
>  //here
> > > > it
> > > > > > returns 0
> > > > > >                                 if (resultCode == RESULT_OK)
> > > > > >                                {
> > > > > >                                        ...........
> > > > > > //Because result code returns 0 therefore this if conditio does
> not
> > > > > > execute.
> > > > > >                                }
> > > > > >                }
> >
> > > > > >        }
> >
> > > > > > And here is my other activity which returns result.
> >
> > > > > > public class RoomList extends ListActivity
> > > > > > {
> > > > > > super.onCreate(savedInstanceState);
> > > > > >        Bundle extras = getIntent().getExtras();
> > > > > >        if(extras !=null)
> > > > > >        {
> > > > > >                value = extras.getString("roomName");
> > > > > >                sw = getSwitchNameArray(value);
> > > > > >        }
> > > > > >        setListAdapter(new ArrayAdapter<String>(this,
> > > > > >                android.R.layout.simple_list_item_multiple_choice,
> > > > > > sw));
> > > > > >        final ListView listView = getListView();
> > > > > >        listView.setItemsCanFocus(true);
> > > > > >        listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
> >
> > > > > > listView.setOnItemClickListener(new
> ListView.OnItemClickListener() {
> >
> > > > > >                        @Override
> > > > > >                        public void onItemClick(AdapterView<?>
> arg0,
> > > > View
> > > > > > arg1, int arg2,
> > > > > >                                        long arg3)
> > > > > >                        {
> > > > > >                                // TODO Auto-generated method stub
> > > > > >                                System.out.println ("User checked
> > > > boxes");
> >
> > > > > >                                if (listView.isItemChecked(arg2))
> > > > > >                                {
> > > > > >                                        System.out.println
> > > > > > ("###"+listView.getItemAtPosition(arg2));
> > > > > >                                        room = (String)
> > > > > > listView.getItemAtPosition(arg2);
> > > > > >                                        selectedRooms.add(room);
> > > > > >                                        System.out.println ("Size
> > > > > > is"+selectedRooms.size());
> >
> > > > > >                                }
> >
> > > > > >                                else
> > > > > >                                {
> > > > > >                                        String str = (String)
> > > > > > listView.getItemAtPosition(arg2);
> > > > > >                                        selectedRooms.remove(str);
> > > > > >                                        System.out.println ("Size
> > > > > > is"+selectedRooms.size());
> > > > > >                                }
> > > > > >                        }
> >
> > > > > >        });
> >
> > > > > > @Override
> > > > > >        protected void onPause()
> > > > > >    {
> > > > > >        super.onPause();
> >
> > > > > >        System.out.println ("User click on back button");
> >
> > > > > >        mySwitches = new String[selectedRooms.size()];
> > > > > >        selectedRooms.toArray(mySwitches);
> > > > > >        int str = mySwitches.length;
> > > > > >        System.out.println ("!...@#!@#...@#"+str);
> > > > > >        Intent returnIntent = new Intent();
> > > > > >        //returnIntent.putExtra("SelectedSwitches",selectedRooms);
> > > > > >        returnIntent.putExtra("SelectedSwitches", str);
> > > > > >        setResult(RESULT_OK,returnIntent);
> > > > > >        System.out.println ("Before calling finish");
> > > > > >        finish();
> > > > > >        System.out.println ("After calling finish");
> > > > > >        }
> >
> > > > > >  public String[] getSwitchNameArray(String rn)
> > > > > >    {
> > > > > > ......returns string array
> > > > > > }
> >
> > > > > > I think in resultCode I get 0 because I write
> > > > > > setResult(RESULT_OK,returnIntent);  inside onPause () method. Or
> there
> > > > > > is another problem? I had write that inside onPause bacause in
> this
> > > > > > activity I am calculating name of selected items. And I never
> knows
> > > > > > when user had finished selecting items. After writing code inside
> > > > > > onPause I know what item user had selected from list and I can
> pass
> > > > > > them to the calling activity.
> >
> > > > > > I think better approach is to add one button means suppose user
> click
> > > > > > on save button then selected item will be sent to the calling
> > > > > > activity. Want your opinion? where should write code. If it
> doesn't
> > > > > > affect write inside onPause() then why I got 0 from resultCode.
> >
> > > > > > --
> > > > > > You received this message because you are subscribed to the
> Google
> > > > > > Groups "Android Developers" group.
> > > > > > To post to this group, send email to
> > > > [email protected]
> > > > > > To unsubscribe from this group, send email to
> > > > > > [email protected]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> >
> > > > <android-developers%[email protected]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> >
> >
> > > > > > 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
> [email protected]
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> >
> > > > 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> 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 [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-developers?hl=en

Reply via email to