我已经列出了弹出菜单中列表视图中的项目,现在我需要使用listview后面的背景布局自定义我的弹出视图。有可能我尝试通过网上冲浪,但我找不到解决方案。提前谢谢。
我的代码:
<?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/item1"
android:showAsAction="ifRoom|withText"
android:title="add"
android:visible="true"/>
<item
android:id="@+id/item2"
android:showAsAction="ifRoom|withText"
android:title="delete"
android:visible="true"/>
<item
android:id="@+id/item3"
android:showAsAction="ifRoom|withText"
android:title="edit"
android:visible="true"/>
</menu>
我想在我的代码中找到什么:
答案 0 :(得分:0)
你可以试试这个 yourButtonViewObject是您单击以显示此弹出窗口的按钮
ListPopupWindow listPopupWindow = new ListPopupWindow(
ListPopupWindowAppActivity.this);
//here you can set your custom adapter aswell
listPopupWindow.setAdapter(new ArrayAdapter(
ListPopupWindowAppActivity.this,
R.layout.list_item, passyourarrayhere));
listPopupWindow.setAnchorView(yourButtonViewObject);
listPopupWindow.setWidth(300);
listPopupWindow.setHeight(400);
listPopupWindow.setModal(true);
listPopupWindow.setOnItemClickListener(
ListPopupWindowAppActivity.this);
//when you click on yourButtonViewObject show listPopupWindow like this
listPopupWindow.show();
//and in onItemClick overiden method do similar as you do in listview