我正在Libgdx中创建一个游戏,为了与android UI交互,我已经创建了界面并调用了类中的方法的超级实现,在Android的主要活动中我已经使用了方法实现并添加了android代码.我尝试运行时遇到此错误?
这是访问android类的接口类及其方法
public interface abcInterface {
public void method1();
Run Code Online (Sandbox Code Playgroud)
}
在Libgdx我称之为这种方法
game.method1(int a,int b);
Run Code Online (Sandbox Code Playgroud)
在主要活动中,我称之为接口方法实现
public void showmethod( final int level, int score)
{
interface.method1(a,b, new interface() {
@Override
public void clickplay() {
//...............
.................//
}
});
}
Run Code Online (Sandbox Code Playgroud)
我试图调用回调方法,但我面临这个错误,需要一些建议和解决方案.
小智 5
用下面的代码更改你的showmethod(),我希望你的问题能够得到解决.
public void showmethod(final int level, int score) {
interface.method1(a, b, new interface() {
@Override
public void clickplay() {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
//............... do your stuf here ................. //
}
});
}
});
}
Run Code Online (Sandbox Code Playgroud)