我有一些线程,我在其中创建一些视图并准备它们显示.其中我也有一个WebView.此代码在线程中执行:
WebView lGraphWebView = null;
try{
lGraphWebView = new WebView(AppController.getAppController());
}catch (Exception e) {
Log.d("info", "error: " +e );
}
Run Code Online (Sandbox Code Playgroud)
并抛出以下异常:
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
Run Code Online (Sandbox Code Playgroud)
这有点奇怪,因为当我创建一个简单的按钮时,一切都还可以.所以,任何人都可以解释为什么在创建WebView时我会得到这个例外,如果Looper.prepare()可以帮到这里吗?提前致谢!
multithreading android android-widget android-webview looper
我尝试在 Android 中使用 NumberFormatter 格式化数字。我使用下面的代码,它完美地工作:
NumberFormat formatter = new DecimalFormat("###,###");
String myFormattedString = formatter.format(123456);
Run Code Online (Sandbox Code Playgroud)
但是,当我使用带有空格的模式时,就像这样:new DecimalFormat("###,# ##");它会抛出一个IllegalArgumentException. 我已经阅读了有关 NumberFormatter 和 DecimalFormatter 的文档,但没有发现有关模式中空格的信息。谁能解释我为什么不能使用空格或如何将它们添加为允许的字符。提前致谢!!!