理念上实施以下弹出菜单中的ListView [英] Idea on implementing the following pop up menu in ListView

查看:159
本文介绍了理念上实施以下弹出菜单中的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有弹出菜单,当我点击了3点区域在的ListView 行。

<一个href="http://developer.android.com/reference/android/app/Activity.html#registerForContextMenu%28android.view.View%29"相对=nofollow> registerForContextMenu 将不能满足我的需要,因为它在长期preSS发生,在任何领域的ListView 行。

我也想知道。

  1. 如何的ListView 行?创建一个3点看UI
  2. 如何拥有PopupMenu的,甚至是Android 2.3的?
解决方案
  1. 您可以使用的ImageView 与3个点显示的图像。

  2. 有两种方式弹出菜单

    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.

  1. How to create a 3 dots looking UI in ListView row?
  2. How to have PopupMenu, even for Android 2.3?

解决方案

  1. You can use ImageView to display image with 3 dots.

  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆