You're doing it onItemClick, so it's probably invalidated for redraw
anyway. In my case the items are coming in on a separate thread. If I
was to click an item it would update then. But of course that's a very
weird interaction to touch the screen and suddenly all of the updates
show up at once.
On Oct 30, 9:28 am, Biosopher <[EMAIL PROTECTED]> wrote:
> I used notifyDataSetChanged() and it works fine for me. Here's my
> complete code with the notifyDataSetChanged() at the bottom in the
> selection listener:
>
> package com.pocketjourney.location.map;
>
> import java.util.List;
>
> import android.content.Context;
> import android.view.LayoutInflater;
> import android.view.View;
> import android.view.ViewGroup;
> import android.widget.AdapterView;
> import android.widget.BaseAdapter;
> import android.widget.ImageView;
> import android.widget.ListView;
> import android.widget.TextView;
> import android.widget.AdapterView.OnItemClickListener;
>
> import com.pocketjourney.R;
> import com.pocketjourney.location.DestinationModel;
>
> public class DestinationTypesListAdapter extends BaseAdapter
> implements OnItemClickListener
>
> {
> private List<String> allTypes, activeTypes;
>
> private ListView destinationTypeList;
>
> public DestinationTypesListAdapter(ListView destinationTypeList)
> {
> this.destinationTypeList = destinationTypeList;
>
> this.allTypes = DestinationModel.getAllDestinationTypes();
> this.activeTypes =
> DestinationModel.getActiveDestinationTypes();
>
> destinationTypeList.setOnItemClickListener(this);
> }
>
> public View getView(int position, View convertView, ViewGroup
> parent)
> {
> View destinationTypeLabel = null;
> if ( convertView == null )
> {
> LayoutInflater inflater =
> (LayoutInflater)parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
> destinationTypeLabel =
> inflater.inflate(R.layout.list_item_destination_type, null);
> } else {
> destinationTypeLabel = convertView;
> }
>
> String destinationType = (String) getItem(position);
> TextView destinationTypeText = (TextView)
> destinationTypeLabel.findViewById(R.id.destination_type);
> destinationTypeText.setText(destinationType);
>
> ImageView typeSelectedImage= (ImageView)
> destinationTypeLabel.findViewById(R.id.destination_type_selected);
> if (activeTypes.contains(destinationType)) {
>
> typeSelectedImage.setImageResource(R.drawable.list_selection_checkmark);
> } else {
> typeSelectedImage.setImageResource(R.drawable.empty);
> }
>
> return destinationTypeLabel;
> }
>
> public int getCount()
> {
> return allTypes.size();
> }
>
> @Override
> public Object getItem(int position)
> {
> return allTypes.get(position);
> }
>
> @Override
> public long getItemId(int position) {
> // We can simply use the array index as a unique id.
> return position;
> }
>
> /**
> * Implementation of OnItemClickListener
> */
> @Override
> public void onItemClick(AdapterView adapterView, View view, int
> position, long id)
> {
> String destinationType = (String) getItem(position);
> if (activeTypes.contains(destinationType)) {
> activeTypes.remove(destinationType);
> } else {
> activeTypes.add(destinationType);
> }
> DestinationModel.setActiveDestinationTypes(activeTypes);
> notifyDataSetChanged();
> }
>
> }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---