日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android仿QQ复制昵称效果2

發布時間:2023/11/29 Android 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android仿QQ复制昵称效果2 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本文同步自http://javaexception.com/archives/77

背景:

在上一篇文章中,給出了一種復制QQ效果的方案,今天就來講講換一種方式實現。主要依賴的是一個開源項目https://github.com/shangmingchao/PopupList。

解決辦法:

PopupList.java的代碼封裝的比較完善,用純java代碼實現view效果,不需要使用圖片,xml資源文件,引入的話,只需要copy PopupList.java代碼到項目工程中。

剩下的就是調用了。這里不分析源碼,源碼比較簡單,只講如何使用的。

PopupList popupList = new PopupList(this); List<String> popupMenuItemList = new ArrayList<>(Arrays.asList("復制QQ號")); popupList.bind(tvQQNum, popupMenuItemList, new PopupList.PopupListListener() {@Overridepublic boolean showPopupList(View adapterView, View contextView, int contextPosition) {return true;}@Overridepublic 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<String> popupMenuItemList = new ArrayList<>(Arrays.asList("復制")); popupList.bind(tvUserName, popupMenuItemList, new PopupList.PopupListListener() {@Overridepublic boolean showPopupList(View adapterView, View contextView, int contextPosition) {return true;}@Overridepublic void onPopupListClick(View contextView, int contextPosition, int position) {ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);ClipData clipData = ClipData.newPlainText("Label", "天天");cm.setPrimaryClip(clipData);} });

用法很簡單。PopupList支持單個,也支持數組形式的結構,如朋友圈點贊的那種效果等。

參考資料:

https://github.com/shangmingchao/PopupList

轉載于:https://www.cnblogs.com/xing-star/p/10799206.html

總結

以上是生活随笔為你收集整理的Android仿QQ复制昵称效果2的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。