如何在 android 中的 baseadapter class 中创建弹出窗口 Window(已关闭)

How to Create Popup Window in baseadapter class in android (closed)

在我的 baseadapter class 中有一个文本视图,当单击操作应用弹出窗口 window 时,弹出窗口 window 包含 1-10 的数字列表。 当我 select 列表中的任何数字时,结果仅影响主列表的最后一行(为其创建适配器)。

我的问题是:弹出窗口window在显示文本视图的地方打开,但我想在特定的整个屏幕上打开它宽度和高度。

这里有谁能解决这个问题吗? 提前致谢... 这是适配器代码 class

public class MyListAdapter extends BaseAdapter
{ 
public View getView(final int position, View v, ViewGroup parent) {

    if (inflater == null)
        inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (v == null) {
        v = inflater.inflate(R.layout.cart_list_item_row, null);

    count = (TextView) v.findViewById(R.id.count);
    count.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                PopupWindow popUp = popupWindowshow(v);
                popUp.showAsDropDown(v, 0, 0);
            }
        });
    }
    return v;
}

private PopupWindow popupWindowshow(View v) {

    final PopupWindow popupWindow = new PopupWindow(activity);
    final ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity, android.R.layout.simple_dropdown_item_1line,
            activity.getResources().getStringArray(R.array.item_arrays));
    final ListView countList = new ListView(activity);

    countList.setAdapter(adapter);

    // set on item selected
    countList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            String data = (String) parent.getItemAtPosition(position);
            Toast.makeText(activity, data, Toast.LENGTH_LONG).show();

            count.setText(data);
            adapter.notifyDataSetChanged();
            popupWindow.dismiss();

        }
    });

    popupWindow.setFocusable(true);
    popupWindow.showAtLocation(v, Gravity.CENTER_VERTICAL, 0, 0);
    popupWindow.setWidth(250);
    popupWindow.setBackgroundDrawable(activity.getResources().getDrawable(R.color.white));
    popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);

    // set the listview as popup content
    popupWindow.setContentView(countList);
    return popupWindow;
}

这个问题通过在基本适配器中的弹出窗口 window 位置使用自定义对话框来解决,因为适配器项目的宽度和高度是弹出窗口 window 的父高度,所以这就是为什么 window 不是全屏。 感谢您抽出时间。