Android中如何实现复制昵称效果-创新互联

本篇内容介绍了“Android中如何实现复制昵称效果”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

罗平ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!

解决办法:


PopupList.java的代码封装的比较完善,用纯java代码实现view效果,不需要使用图片,xml资源文件,引入的话,只需要copy PopupList.java代码到项目工程中。

剩下的就是调用了。这里不分析源码,源码比较简单,只讲如何使用的。

PopupList popupList = new PopupList(this);
List popupMenuItemList = new ArrayList<>(Arrays.asList("复制QQ号"));
popupList.bind(tvQQNum, popupMenuItemList, new PopupList.PopupListListener() {
 @Override
 public boolean showPopupList(View adapterView, View contextView, int contextPosition) {
  return true;
 }
 
 @Override
 public void onPopupListClick(View contextView, int contextPosition, int position) {
  ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
  ClipData clipData = ClipData.newPlainText("Label", "10001");
  cm.setPrimaryClip(clipData);
 }
});

PopupList popupList = new PopupList(this);
List popupMenuItemList = new ArrayList<>(Arrays.asList("复制"));
popupList.bind(tvUserName, popupMenuItemList, new PopupList.PopupListListener() {
 @Override
 public boolean showPopupList(View adapterView, View contextView, int contextPosition) {
  return true;
 }
 
 @Override
 public void onPopupListClick(View contextView, int contextPosition, int position) {
  ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
  ClipData clipData = ClipData.newPlainText("Label", "天天");
  cm.setPrimaryClip(clipData);
 }
});

“Android中如何实现复制昵称效果”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!


文章标题:Android中如何实现复制昵称效果-创新互联
转载来于:http://scyanting.com/article/ccjhgo.html