Monday, December 6, 2010

[android-developers] Re: Problem removing from listView

I'm not trying to clear the list
I'm trying to remove all names that are equal to the name you asked to
remove.

you have a list of
bob
bob
tom
tim
sam
suzie

you click on one bob, both bobs get removed

On Dec 6, 7:28 pm, Bret Foreman <bret.fore...@gmail.com> wrote:
> This is simpler:
>
> while( Name.size() > 0 ) {
>   Name.remove(0);
>
> }
>
> On Dec 6, 3:59 pm, Kevin Anthony <kevin.s.anth...@gmail.com> wrote:
>
>
>
>
>
>
>
> > i have a List<String declared like this:
> > private static List<String> Name = new ArrayList<String>();
> > private static List<String> Number = new ArrayList<String>();
> > private static List<String> Address = new ArrayList<String>();
> > private static List<String> Email = new ArrayList<String>();
>
> > and i'm trying to loop threw and delete them when a user longclicks on
> > them and clicks delete
> > here's the delete code:
>
> > public void deleteName(long id){
> >                 String name = Name.get((int)id);
> >                 for (int i = 0; i < Name.size();i++) {
> >                         if (Name.get(i)== name){
> >                                 Name.remove(i);
> >                                 Number.remove(i);
> >                                 Address.remove(i);
> >                                 Email.remove(i);
> >                         }
> >                 }
> >                 return;
> >         }
>
> > however, it only deletes the entry you click on, not all entries, i've
> > done some log outputting and the Entries all look the same to my eye,
> > even capilization.
>
> > What am i doing wrong?
>
> > Thanks
> > Kevin A

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment