亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android仿QQ長(zhǎng)按刪除彈出框功能示例

 更新時(shí)間:2017年03月09日 10:09:01   作者:shangmingchao  
對(duì)于列表來(lái)說,如果想操作某個(gè)列表項(xiàng),一般會(huì)采用長(zhǎng)按彈出菜單的形式,默認(rèn)的上下文菜單比較難看,而QQ的上下文菜單就人性化多了,整個(gè)菜單給用戶一種氣泡彈出的感覺,而且會(huì)顯示在手指按下的位置,接下來(lái)通過本文給大家分享Android仿QQ長(zhǎng)按刪除彈出框功能,一起看看吧

  廢話不說,先看一下效果圖,如果大家感覺不錯(cuò),請(qǐng)參考實(shí)現(xiàn)代碼:

        對(duì)于列表來(lái)說,如果想操作某個(gè)列表項(xiàng),一般會(huì)采用長(zhǎng)按彈出菜單的形式,默認(rèn)的上下文菜單比較難看,而QQ的上下文菜單就人性化多了,整個(gè)菜單給用戶一種氣泡彈出的感覺,而且會(huì)顯示在手指按下的位置,而技術(shù)實(shí)現(xiàn)我之前是使用popupWindowRecyclerView實(shí)現(xiàn)的,上面一個(gè)RecyclerView,下面一個(gè)小箭頭ImageView,但后來(lái)發(fā)現(xiàn)沒有必要,而且可定制化也不高,還是使用多個(gè)TextView更好一點(diǎn)。

        我封裝了一下,只需要一個(gè)PopupList.Java文件。源碼放在了Git上,git地址:

https://github.com/shangmingchao/PopupList

        使用方式,很簡(jiǎn)單:

        只需要調(diào)用該方法即可完成綁定:

PopupList popupList = new PopupList(); 
popupList.init(context, view, popupMenuItemList, OnPopupListClickListener); 

        例子:

lv_main = (ListView) findViewById(R.id.lv_main); 
mDataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, mDataList); 
lv_main.setAdapter(mDataAdapter); 
popupMenuItemList.add(getString(R.string.copy)); 
popupMenuItemList.add(getString(R.string.delete)); 
popupMenuItemList.add(getString(R.string.share)); 
popupMenuItemList.add(getString(R.string.more)); 
PopupList popupList = new PopupList(); 
popupList.init(this, lv_main, popupMenuItemList, new PopupList.OnPopupListClickListener() { 
 @Override 
 public void onPopupListClick(View contextView, int contextPosition, int position) { 
 Toast.makeText(MainActivity.this, contextPosition + "," + position, Toast.LENGTH_LONG).show(); 
 } 
}); 
ImageView indicator = new ImageView(this); 
indicator.setImageResource(R.drawable.popuplist_default_arrow); 
popupList.setIndicatorView(indicator); 
popupList.setIndicatorSize(dp2px(16), dp2px(8)); 

以上所述是小編給大家介紹的Android仿QQ長(zhǎng)按刪除彈出框功能示例,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論