我正在使 ListView 动态显示在选定的特定项目下方。有人可以建议我这怎么可能吗?我在这里证明了快照。
我的代码如下。
root.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// im++;
final ListPopupWindow listPopupWindow = new ListPopupWindow(getActivity());
ArrayList<String> a=new ArrayList<String>();
a.add("a");
a.add("b");
listPopupWindow.setAdapter(new ArrayAdapter(
getActivity(),
R.layout.raw_comment,a.size()));
listPopupWindow.setAnchorView(v);
listPopupWindow.show();
//showAlertDialog(getActivity(), "List display 1");
}
});
您的回答将不胜感激
最佳答案
试试这个
final ListPopupWindow listPopupWindow = new ListPopupWindow(
context);
listPopupWindow.setAdapter(new ArrayAdapter(
context,
R.layout.list_row_layout, arrayOfValues));
listPopupWindow.setAnchorView(your_view);
listPopupWindow.setWidth(300);
listPopupWindow.show();
关于android - 如何在选定的特定项目下方显示列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33580306/