QPopuWindow 类型聊天消息 长按事件 选项

说下重点吧。先导入这个第三方

然后在item 的点击事件 添加代码

 QPopuWindow.getInstance(ListViewActivity.this).builder
                        .bindView(view, position)
                        .setPopupItemList(new String[]{"复制", "粘贴", "转发", "更多...."})
                        .setPointers(rawX, rawY)
                        .setOnPopuListItemClickListener(new QPopuWindow.OnPopuListItemClickListener() {
                            /**
                             * @param anchorView 为pop的绑定view
                             * @param anchorViewPosition  pop绑定view在ListView的position
                             * @param position  pop点击item的position 第一个位置索引为0
                             */
                            @Override
                            public void onPopuListItemClick(View anchorView, int anchorViewPosition, int position) {
                                Toast.makeText(ListViewActivity.this, anchorViewPosition + "---->" + position, Toast.LENGTH_SHORT).show();
                            }
                        }).show();

至于这个anchorViewPosition + "---->" + position 得给自己长个记性

switch (position) {//anchorViewPosition 每一条的数。
    case 0:
        showRename(anchorViewPosition);//重命名
        break;
    case 1:
        getDeleteDialog(anchorViewPosition);//删除
        break;
    case 2:
        if (AppNetworkMgr.isNetworkConnected(MainActivity.this)) {
            Log.e("连接", "连接");
            //发送
            Recorder recorder = mDates.get(anchorViewPosition);
            String enter_str = filePath + recorder.getFileName() + "_" + recorder.getFileTime() + ".wav";//旧文件
            CopyUtils.copyFile(enter_str, Environment.getExternalStorageDirectory() + "/xxxxx/" + recorder.getFileName() + ".wav");
            Intent share = new Intent(Intent.ACTION_SEND);
            //创建组件
            ComponentName component = new ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity");
            share.setComponent(component);        //设置组件
            share.putExtra(Intent.EXTRA_STREAM, (FileProvider.getUriForFile(MainActivity.this, getApplicationContext().getPackageName() + ".provider", new File(Environment.getExternalStorageDirectory() + "/果乐录音ZIP/" + recorder.getFileName() + ".wav"))));
            share.setType("*/*");
            startActivity(Intent.createChooser(share, "分享到"));
        } else {
            Log.e("不连接", "不连接");
            Toast.makeText(MainActivity.this, "网络未连接", Toast.LENGTH_SHORT).show();
        }

        break;

希望能帮助到大家。一同奋进吧!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值