理念上实施以下弹出菜单中的ListView [英] Idea on implementing the following pop up menu in ListView
问题描述
我想有弹出菜单,当我点击了3点区域在的ListView
行。
<一个href="http://developer.android.com/reference/android/app/Activity.html#registerForContextMenu%28android.view.View%29"相对=nofollow> registerForContextMenu
将不能满足我的需要,因为它在长期preSS发生,在任何领域的ListView
行。
我也想知道。
- 如何
的ListView
行?创建一个3点看UI - 如何拥有PopupMenu的,甚至是Android 2.3的?
-
您可以使用
的ImageView
与3个点显示的图像。 -
有两种方式弹出菜单
a)使用一些布局和使其可见/不见了
二)使用
PopupWindow
。
下面是示例$ C $下PopupWindow
PopupWindow popupWindow =新PopupWindow(上下文);
查看popUpView = View.inflate(活动的LinearLayout,NULL);
popUpView.setBackgroundColor(Color.TRANSPARENT);
mpopup.setContentView(popUpView);
mpopup.setHeight(LayoutParams.WRAP_CONTENT);
mpopup.setWidth(LayoutParams.WRAP_CONTENT);
mpopup.setFocusable(真正的);
mpopup.setBackgroundDrawable(activity.getResources()getDrawable(R.drawable.transperent));
mpopup.setOutsideTouchable(真正的);
mpopup.setAnimationStyle(R.anim.slide_out_up);
mpopup.showAtLocation(popUpView,Gravity.TOP,activity.getResources()
.getInteger(R.integer.log_out_popup_x),activity.getResources()
.getInteger(R.integer.log_out_popup_y));
I would like to have pop up menu, when I click on the 3 dots area in a ListView
row.
registerForContextMenu
won't meet my need, as it happen during long press, in any area of ListView
row.
I would like to know.
- How to create a 3 dots looking UI in
ListView
row? - How to have PopupMenu, even for Android 2.3?
You can use
ImageView
to display image with 3 dots.There are two ways for popupmenu
a) Use some layouts and make them visible/gone
b) Use
PopupWindow
.
here is sample code for PopupWindow
PopupWindow popupWindow = new PopupWindow(context);
View popUpView = View.inflate(activity, linearlayout, null);
popUpView.setBackgroundColor(Color.TRANSPARENT);
mpopup.setContentView(popUpView);
mpopup.setHeight(LayoutParams.WRAP_CONTENT);
mpopup.setWidth(LayoutParams.WRAP_CONTENT);
mpopup.setFocusable(true);
mpopup.setBackgroundDrawable(activity.getResources().getDrawable(R.drawable.transperent));
mpopup.setOutsideTouchable(true);
mpopup.setAnimationStyle(R.anim.slide_out_up);
mpopup.showAtLocation(popUpView, Gravity.TOP, activity.getResources()
.getInteger(R.integer.log_out_popup_x), activity.getResources()
.getInteger(R.integer.log_out_popup_y));
这篇关于理念上实施以下弹出菜单中的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!