WebView 打开弹窗活动出错,魅族手机出错

Thread [JavaBridge] (Suspended (exception ViewRootImpl$CalledFromWrongThreadException))

ViewRootImpl.checkThread() line: 6531

ViewRootImpl.invalidateChildInParent(int[], Rect) line: 913

RelativeLayout(ViewGroup).invalidateChild(View, Rect) line: 4702

RelativeLayout(View).invalidateInternal(int, int, int, int, boolean, boolean) line: 11836

RelativeLayout(View).invalidate(boolean) line: 11800

Button(View).setFlags(int, int) line: 9805

Button(View).setVisibility(int) line: 6707

CommonWebViewScriptBarActivity.closeModel() line: 631

WebViewScript.CloseModelPopView() line: 122

SystemMessageHandler.nativeDoRunLoopOnce(long, long) line: not available [native method]

SystemMessageHandler.handleMessage(Message) line: 53

SystemMessageHandler(Handler).dispatchMessage(Message) line: 102

Looper.loop() line: 135

HandlerThread.run() line: 61

解决方案如下:

主线程建Handler

private class  MainHandler  extends Handler{

/**

* Subclasses must implement this to receive messages.

*/

public void handleMessage(Message msg) {

switch(msg.what){

case 1:

btnRight.setVisibility(View.INVISIBLE);

btnRight.setText("");

break;

default:

break;

}

}

}

Message msg = new Message();

msg.what = 0;

mainHandler.sendMessage(msg);

这样就ok了

你可能感兴趣的:(WebView 打开弹窗活动出错,魅族手机出错)