我有一个 javascript 接口类来接收来自 javascript 的一些值。我从接口类中烘烤了该值,但我无法将该值设置为 TextVie。会有什么问题??
class JavaScriptInterfaceForCount {
Context mContext;
JavaScriptInterfaceForCount(Context c) {
mContext = c;
}
public void receiveValueFromJs(String scrollwidth, String columwidth) {
mPagenumberTextView.setText(scrollwidth+"");
}
}
日志猫结果
06-08 16:20:37.003: E/AndroidRuntime(1198): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.view.ViewRoot.checkThread(ViewRoot.java:2802)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.view.ViewRoot.requestLayout(ViewRoot.java:594)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.view.View.requestLayout(View.java:8125)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.view.View.requestLayout(View.java:8125)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.view.View.requestLayout(View.java:8125)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.view.View.requestLayout(View.java:8125)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:254)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.view.View.requestLayout(View.java:8125)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.widget.TextView.checkForRelayout(TextView.java:5378)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.widget.TextView.setText(TextView.java:2688)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.widget.TextView.setText(TextView.java:2556)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.widget.TextView.setText(TextView.java:2531)
06-08 16:20:37.003: E/AndroidRuntime(1198): at com.epub.reader.TestWebActivity$JavaScriptInterfaceForCount.receiveValueFromJs(TestWebActivity.java:326)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.webkit.BrowserFrame.stringByEvaluatingJavaScriptFromString(Native Method)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.webkit.BrowserFrame.stringByEvaluatingJavaScriptFromString(Native Method)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.webkit.BrowserFrame.loadUrl(BrowserFrame.java:245)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.webkit.WebViewCore.loadUrl(WebViewCore.java:1562)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.webkit.WebViewCore.access$1400(WebViewCore.java:52)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:948)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.os.Handler.dispatchMessage(Handler.java:99)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.os.Looper.loop(Looper.java:123)
06-08 16:20:37.003: E/AndroidRuntime(1198): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:621)
06-08 16:20:37.003: E/AndroidRuntime(1198): at java.lang.Thread.run(Thread.java:1096)