以下异常的意思是什么?我该如何修复它?
这是代码:
这是代码:
Toast toast = Toast.makeText(mContext, "Something", Toast.LENGTH_SHORT);
这是异常情况:
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:121)
at android.widget.Toast.<init>(Toast.java:68)
at android.widget.Toast.makeText(Toast.java:231)
compile 'com.shamanland:xdroid-toaster:0.0.5'
,它不需要runOnUiThread()
或Context
变量,所有例行程序都已消失!只需调用Toaster.toast(R.string.my_msg);
就可以了。这里有一个示例:https://github.com/shamanland/xdroid-toaster-example - Oleksii K.