怎么在Android应用中添加一个长按删除弹功能

今天就跟大家聊聊有关怎么在Android应用中添加一个长按删除弹功能,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

只需要调用该方法即可完成绑定:

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应用中添加一个长按删除弹功能有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。