• 大小: 929KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: 其他
  • 标签: 微信  滑动删除  

资源简介

仿微信对话列表滑动删除功能,在listview中可以滑动删除item

资源截图

代码片段和文件信息

package com.ryg.slideview;

import com.ryg.slideview.MainActivity.MessageItem;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ListView;

public class ListViewCompat extends ListView {

    private static final String TAG = “ListViewCompat“;

    private SlideView mFocusedItemView;

    public ListViewCompat(Context context) {
        super(context);
    }

    public ListViewCompat(Context context AttributeSet attrs) {
        super(context attrs);
    }

    public ListViewCompat(Context context AttributeSet attrs int defstyle) {
        super(context attrs defstyle);
    }

    public void shrinkListItem(int position) {
        View item = getChildAt(position);

        if (item != null) {
            try {
                ((SlideView) item).shrink();
            } catch (ClassCastException e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN: {
            int x = (int) event.getX();
            int y = (int) event.getY();
            int position = pointToPosition(x y);
            Log.e(TAG “postion=“ + position);
            if (position != INVALID_POSITION) {
                MessageItem data = (MessageItem) getItemAtPosition(position);
                mFocusedItemView = data.slideView;
                Log.e(TAG “FocusedItemView=“ + mFocusedItemView);
            }
        }
        default:
            break;
        }

        if (mFocusedItemView != null) {
            mFocusedItemView.onRequireTouchEvent(event);
        }

        return super.onTouchEvent(event);
    }

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-12-23 23:07  SlideView\
     文件         466  2013-12-22 11:47  SlideView\.classpath
     文件         812  2013-12-22 11:47  SlideView\.project
     文件         876  2013-12-22 21:41  SlideView\AndroidManifest.xml
     目录           0  2013-12-22 11:47  SlideView\assets\
     目录           0  2013-12-23 23:06  SlideView\bin\
     文件      299567  2013-12-23 23:05  SlideView\bin\SlideView.apk
     目录           0  2013-12-23 23:06  SlideView\gen\
     文件       51394  2013-12-22 11:47  SlideView\ic_launcher-web.png
     目录           0  2013-12-22 11:47  SlideView\libs\
     文件      621451  2013-12-22 11:47  SlideView\libs\android-support-v4.jar
     文件         781  2013-12-22 11:47  SlideView\proguard-project.txt
     文件         563  2013-12-22 22:10  SlideView\project.properties
     目录           0  2013-12-22 14:20  SlideView\res\
     目录           0  2013-12-23 22:54  SlideView\res\drawable\
     目录           0  2013-12-22 19:07  SlideView\res\drawable-hdpi\
     文件        2300  2013-12-22 18:22  SlideView\res\drawable-hdpi\default_qq_avatar.png
     文件         351  2013-12-22 18:10  SlideView\res\drawable-hdpi\del_icon_normal.png
     文件        7658  2013-12-22 11:47  SlideView\res\drawable-hdpi\ic_launcher.png
     文件        3668  2013-12-22 18:13  SlideView\res\drawable-hdpi\wechat_icon.png
     目录           0  2013-12-22 11:47  SlideView\res\drawable-mdpi\
     文件        3777  2013-12-22 11:47  SlideView\res\drawable-mdpi\ic_launcher.png
     目录           0  2013-12-22 11:47  SlideView\res\drawable-xhdpi\
     文件       12516  2013-12-22 11:47  SlideView\res\drawable-xhdpi\ic_launcher.png
     目录           0  2013-12-22 11:47  SlideView\res\drawable-xxhdpi\
     文件       24777  2013-12-22 11:47  SlideView\res\drawable-xxhdpi\ic_launcher.png
     文件         532  2013-12-23 22:54  SlideView\res\drawable\holder_bg.xml
     文件        2816  2013-12-22 19:41  SlideView\res\drawable\item_point_bg.png
     文件         580  2013-12-22 19:42  SlideView\res\drawable\list_item_bg.xml
     目录           0  2013-12-22 18:30  SlideView\res\layout\
     文件         690  2013-12-22 20:04  SlideView\res\layout\activity_main.xml
............此处省略14个文件信息

评论

共有 条评论