popupWindow中包含Gridview

private void showPopwindow() {
    final View popView = View.inflate(this, R.layout.item_config_popup, null);
    final PopupWindow popupWindow = new PopupWindow(popView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    popView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

    GridView mGridView = popView.findViewById(R.id.gv_car_list);
    CarGridviewAdapter gridviewadapter = new CarGridviewAdapter(mContext, groupList);
    mGridView.setAdapter(gridviewadapter);
    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mExpandablelistview.setSelectedGroup(position);
            popupWindow.dismiss();
        }
    });

    int[] location = new int[2];
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.setOutsideTouchable(true);
    popupWindow.setFocusable(true);
    mIv_config.getLocationOnScreen(location);
    popupWindow.showAtLocation(mIv_config, Gravity.NO_GRAVITY, 0, location[1] - 450);
    popupWindow.update();
}

猜你喜欢

转载自blog.csdn.net/zhangkaiyazky/article/details/80888584
今日推荐