您的位置:首页 > 移动开发 > Android开发

No enclosing instance of type * is accessible.

2016-05-10 09:32 676 查看
这是我项目中遇到的问题:



报错内容:No enclosing instance of type * is accessible. Must qualify the allocation with an enclosing instance of type * (e.g. x.new A() where x is an instance of  * ).

class 直接写的是动态的内部类,可是主程序是public static void main。 (静态类)
Java中,类中的静态方法不能直接调用动态方法。只有将某个内部类修饰为静态类,然后才能够在静态类中调用该类的成员变量与成员方法。 
所以,最简单的解决办法是为 class  添加修饰 static ,使其为静态内部类 static class

问题就得到了解决
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android