【问题标题】:How to display drop-down list-view below particular view in android?如何在android中的特定视图下方显示下拉列表视图?
【发布时间】:2017-06-29 12:08:32
【问题描述】:
我有一个过滤器按钮。我需要打开与下图相同的可扩展/下拉过滤器。我尝试了弹出菜单和 Listpopup 窗口,但没有成功。
提前致谢
【问题讨论】:
标签:
java
android
expandablelistview
【解决方案1】:
您可以使用过滤器按钮下方的片段,布局将包括您期望的用户界面,即上箭头和可扩展视图或您正在使用的任何视图..
单击过滤器后,仅可见片段并带有片段过渡,对于效果,您也可以使用动画...
我已经完成了,您可以参考 carwale 应用二手车部分..单击过滤器按钮会出现一个相同的 dilog..
有任何事情请让我进一步了解..
【解决方案2】:
我在上述 cmets 的帮助下编写了代码。但代码如下所示。
final View popUpView = getLayoutInflater().inflate(R.layout.exp, null);
listPopupWindow = new PopupWindow(popUpView, LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT, true);
expandableListView= (ExpandableListView) popUpView.findViewById(R.id.expandableListView);
btnticker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
expandableListDetail = ExpandableListDataPump.getData();
expandableListTitle = new ArrayList<String>(expandableListDetail.keySet());
expandableListAdapter = new CustomExpandableListAdapter(MainActivity.this, expandableListTitle, expandableListDetail);
expandableListView.setAdapter(expandableListAdapter);
listPopupWindow.showAsDropDown(v);
}
});