При щелчке элемента в адаптере утилизатора во фрагменте отобразится пользовательское всплывающее окно. - PullRequest
0 голосов
/ 26 сентября 2018

У меня есть адаптер представления переработчика внутри фрагмента.

При нажатии на элементы в адаптере я хочу отобразить пользовательское всплывающее окно.

Ниже приведен код для того же

В onBindViewHolder :

holder.profileImageView.setOnLongClickListener(view -> {

            PopupWindow optionPopUp;

            View rootView = ((Activity)context).getWindow().getDecorView().findViewById(R.id.board_info_id);
            LinearLayout v = rootView.findViewById(R.id.owner_options_popup);

            LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View layout = layoutInflater.inflate(R.layout.owner_options_for_admin_or_user_popup, v);

            int[] location = new int[2];

            view.getLocationOnScreen(location);

            //Initialize the Point with x, and y positions
            Point point = new Point();
            point.x = location[0];
            point.y = location[1];

            // Displaying the popup at the specified location, + offsets.

            optionPopUp = new PopupWindow(context);
            optionPopUp.setContentView(layout);
            optionPopUp.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
            optionPopUp.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
            optionPopUp.setFocusable(true);

            //Clear the default translucent background
            optionPopUp.setBackgroundDrawable(new BitmapDrawable());

            // Displaying the popup at the specified location, + offsets.
            optionPopUp.showAtLocation(layout, Gravity.NO_GRAVITY, point.x , point.y );

            return true;
        });

На линии

View rootView = ((Activity)context).getWindow().getDecorView().findViewById(R.id.board_info_id);

Я получаю следующую ошибку

не может быть приведенto android.app.Activity

Может кто-нибудь указать, что не так в том, что я делаю?

...