Android:由于:MenuPopup,在此上下文中无法访问typesMenuPopup

我想从我自己的包名称空间访问MenuPopup实例。 我不知道这个错误,我是tiro 🙁 …

PopupMenu文件

码:

 class XMenuPopup { // .... internal val mPopup: MenuPopupHelper // ... fun show() { // Error notice is here // Type MenuPopup is inaccessible in this context due to: MenuPopup mPopup.popup } } 

看来你想使用的类是私有的,在这种情况下是不可访问的。 也许你应该尝试使用如下的inheritance

 class XMenuPopup : MenuPopup { 

也请检查: http : //antonioleiva.com/kotlin-android-custom-views/

希望这会有所帮助