bauerca / drag-sort-listview

Android ListView with drag and drop reordering.
3.2k stars 1.44k forks source link

Drag and Drop is not working when we use custom adapter with ImageView #145

Open kaminiprasad opened 9 years ago

kaminiprasad commented 9 years ago

Hi, am trying to implement drag and drop functionality using drag-sort-listview. But when I implement with custom adapter with image and text, sorting is not done if we change the positions of the view(i.e images don't change their position). Can some help me. Below is is my getView(-,-,-) in customadapter.

Does this lib work when we try to sort of images ? device-2015-08-28-130653

public View getView(int position, View convertView, ViewGroup parent) {

        ListViewHolder holder=null;
        if(convertView==null){

            LayoutInflater inflater = LayoutInflater.from(context);
            convertView = inflater.inflate(R.layout.pptimagelist_row_item, parent, false);
            holder = new ListViewHolder();

            holder.imageViewImageListRowItem = (ImageView) convertView.findViewById(R.id.imageViewImageListRowItem);
            holder.imageViewListRowItemView = (ImageView) convertView.findViewById(R.id.imageViewListRowItemView);
            holder.imageViewListRowItemDelete = (ImageView) convertView.findViewById(R.id.imageViewListRowItemDelete);
            holder.imageViewListRowItemDrag = (ImageView) convertView.findViewById(R.id.imageViewListRowItemDrag);

            holder.textViewImageListRowItemTitle = (TextView) convertView.findViewById(R.id.textViewImageListRowItemTitle);
            holder.textViewImageListRowItemDescription = (TextView) convertView.findViewById(R.id.textViewImageListRowItemDescription);

            holder.belowText = (TextView) convertView.findViewById(R.id.below_text);
            holder.textViewImageListRowItemDescription.setVisibility(View.GONE);

            holder.textViewImageListRowItemTitle.setText(presItems.get(position).getChapterName());   

            if(presItems.get(position).getImageUri() != null){
                holder.imageViewImageListRowItem.setImageURI(Uri.parse(presItems.get(position).getImageUri()));
            }

            convertView.setTag(holder);

        }else{
            holder=(ListViewHolder) convertView.getTag();
        }
        return convertView;
    }