小编dad*_*chi的帖子

在屏幕的最左侧显示ListPopupWindow

我可以通过以下代码在屏幕的大多数左侧显示ListPopupWindow.

@Override
public View onCreateActionView() {
    LayoutInflater layoutInflater = LayoutInflater.from(mContext);

    final View actionItem = layoutInflater.inflate(R.layout.list_table_view_action_provider, null);

    final ImageButton button = (ImageButton) actionItem.findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mListPopupWindow = new ListPopupWindow(mContext);
            mListPopupWindow.setAnchorView(actionItem);
            mListPopupWindow.setAdapter(mAdapter);
            mListPopupWindow.setModal(true);
            mListPopupWindow.setContentWidth(150);

            // Display mListPopupWindow on most left of the screen
            mListPopupWindow.setHorizontalOffset(-1000);


            mListPopupWindow.setOnItemClickListener(ListTableViewActionProvider.this);

            mListPopupWindow.show();
            mListPopupWindow.setOnDismissListener(ListTableViewActionProvider.this);
        }
    });

    return actionItem;
}
Run Code Online (Sandbox Code Playgroud)

"mListPopupWindow.setHorizo​​ntalOffset(-1000);" 太糟糕了.还有其他解决方案吗?

android

5
推荐指数
0
解决办法
3927
查看次数

标签 统计

android ×1