Android: Type MenuPopup is inaccessible in this context due to: MenuPopup


#1

I want to access MenuPopup instance from my own package namespace . i have no idea about this error, i am tiro :frowning:

PopupMenu Doc
https://developer.android.com/reference/android/support/v7/widget/PopupMenu.html


#2

Please show the specific code fragment where you see this error.


#3

Of course .

class XMenuPopup {
  // ....
 internal val mPopup: MenuPopupHelper

 // ...
  fun show() {
        mPopup.show()

        // Error notice is here ( Type MenuPopup is inaccessible in this context due to: MenuPopup )
        mPopup.popup
    }
}

#4

How is MenuPopupHelper and its popup property defined?


#5

it’s from android sdk .

package android.support.v7.view.menu;

public class MenuPopupHelper implements MenuHelper {
    // code ...
    private MenuPopup mPopup;
   
    // code ...
    @NonNull
    public MenuPopup getPopup() {
        if (mPopup == null) {
            mPopup = createPopup();
        }
        return mPopup;
    }

}