仿QQ消息控件 SwipeRefreshDemo

未知
Java 查看源码»
Android
2016-04-25
开源中国股瞎

SwipeRefreshDemo

自定义组合控件上拉+下拉+左滑删除置顶

look at the screenshot:

高仿微信群聊头像

使用方法

build.gradle文件

compile 'com.hankkin:swiperefresh:1.0.1

xml引用

 <com.hankkin.library.RefreshSwipeMenuListView
        android:id="@+id/swipe"
        android:dividerHeight="1dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

创建左滑菜单

      rsmLv.setAdapter(adapter);
        rsmLv.setListViewMode(RefreshSwipeMenuListView.HEADER);
        rsmLv.setOnRefreshListener(this);

        SwipeMenuCreator creator = new SwipeMenuCreator() {
            @Override
            public void create(SwipeMenu menu) {
                // 创建滑动选项
                SwipeMenuItem rejectItem = new SwipeMenuItem(
                        getApplicationContext());
                // 设置选项背景
                rejectItem.setBackground(new ColorDrawable(getResources().getColor(R.color.top)));
                // 设置选项宽度
                rejectItem.setWidth(dp2px(80,getApplicationContext()));
                // 设置选项标题
                rejectItem.setTitle("置顶");
                // 设置选项标题
                rejectItem.setTitleSize(16);
                // 设置选项标题颜色
                rejectItem.setTitleColor(Color.WHITE);
                // 添加选项
                menu.addMenuItem(rejectItem);

                // 创建删除选项
                SwipeMenuItem argeeItem = new SwipeMenuItem(getApplicationContext());
                argeeItem.setBackground(new ColorDrawable(getResources().getColor(R.color.del)));
                argeeItem.setWidth(dp2px(80, getApplicationContext()));
                argeeItem.setTitle("删除");
                argeeItem.setTitleSize(16);
                argeeItem.setTitleColor(Color.WHITE);
                menu.addMenuItem(argeeItem);
            }
        };
        rsmLv.setMenuCreator(creator);

左滑菜单监听

rsmLv.setOnMenuItemClickListener(new RefreshSwipeMenuListView.OnMenuItemClickListener() {
            @Override
            public void onMenuItemClick(int position, SwipeMenu menu, int index) {
                switch (index) {
                    case 0: //第一个选项
                        Toast.makeText(MainActivity.this,"您点击的是置顶",Toast.LENGTH_SHORT).show();
                        break;
                    case 1: //第二个选项
                        del(position,rsmLv.getChildAt(position+1-rsmLv.getFirstVisiblePosition()));
                        break;

                }
            }
        });
的码云指数为
超过 的项目
加载中

评论(1)

howeye
howeye
外层套了viewPager后就滑不动了

暂无资讯

暂无问答

android SwipeRefreshLayout 增加上拉加载更多

android 谷歌官方自带下拉刷新,并加上上拉加载更多。主要熟悉下SwipeRefreshLayout 的使用.

2015/01/19 17:46
1K
1

没有更多内容

加载失败,请刷新页面

没有更多内容

返回顶部
顶部