其他人有类似的错误,虽然这个是不同的,特别是因为getListView()
java.lang.NullPointerException:尝试调用虚方法' android.widget.ListView cookiemaster.cookieclicker.MainActivity $ ItemsList.getListView()'在空对象引用上
@Override
public void TimerTick()
{
runOnUiThread(new Runnable() {
@Override
public void run() {
totalCookies.setText("Total: " + Beautify.CommaSeparate((int)(Game.getInstance().getTotal())));
CookiesPerSec.setText(Beautify.CommaSeparateDouble(Math.round(Game.getInstance().getCps() * 100.0) / 100.0) + " CPS");
try{ ItemsList.getListView().invalidateViews(); }
catch(IllegalStateException e){}
}
});
}
Logcat:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.widget.ListView cookiemaster.cookieclicker.MainActivity$ItemsList.getListView()' on a null object reference
at cookiemaster.cookieclicker.MainActivity$3.run(MainActivity.java:136)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)