我想在我的項目來實現搜索條,JavaScript代碼是:不能使用loadURL的JavaScript在Android Studio中
seekBarR.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
int progressChangedValue = 0;
WebView myWeb;
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
progressChangedValue = progress;
myWeb.loadUrl("javascript:polyhedronGenerator.radius='+progress+'");
myWeb.loadUrl("javascript:polyhedronGenerator.Redraw(0)");
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStopTrackingTouch(SeekBar seekBar) {
Toast.makeText(nav_two_hard.this, "Seek bar progress is :" + progressChangedValue,
Toast.LENGTH_SHORT).show();
}
});
的JavaScript代碼是:
polyhedronGenerator.radius=100
polyhedronGenerator.Redraw(2)
多面體的半徑應該由seekbar的移動來改變。
我得到的錯誤是這樣的:
11月8日至八日:18:36.114 26557-26557/com.example.jzhu26.testui E/InputEventReceiver:異常調度輸入事件。 E/MessageQueue-JNI:MessageQueue回調中的異常:handleReceiveCallback 08-08 11:18:36.116 26557-26557/com.example.jzhu26 .testui E/MessageQueue-JNI:java.lang.NullPointerException:試圖在null對象引用 com.example.jzhu26.testui上調用虛擬方法'void android.webkit.WebView.loadUrl(java.lang.String)' .nav_two_hard $ 1.onProgressChanged(nav_two_hard.java:96) 在android.widget.SeekBar.onProgressRefresh(SeekBar.java:93) 在android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:1303) 在android.widget。 ProgressBar.refreshProgress(ProgressBar.java:1315) at android.widget.ProgressBar.s etProgress(ProgressBar.java:1361) 在android.widget.AbsSeekBar.trackTouchEvent(AbsSeekBar.java:666) 在android.widget.AbsSeekBar.onTouchEvent(AbsSeekBar.java:579) 在android.view.View.dispatchTouchEvent( View.java:9300) 在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197) 在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup中。 java:2553) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197) 在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197) 在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197) 在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 在機器人。 view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197) 在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197) 在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 在android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197) 在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 在機器人。 view.ViewGroup.dispatchTouchEvent(ViewGroup中。在Android上的com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737) 。 app.Activity.dispatchTouchEvent(Activity.java:2771) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:63) at com.android.internal.policy.PhoneWindow $ DecorView.dispatchTouchEvent(PhoneWindow。在android.view.View.RootImpl $ ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230)在android.view.ViewRootImpl $ InputStage.deliver(ViewRootImpl.java:3642) at android.view.ViewRootImpl $ InputStage.onDeliverToNext(ViewRootImpl。 android.view.ViewRootImpl $ InputStage.forward(ViewRootImpl.java:3661) at android.view.ViewRootImpl $ AsyncInputStage.forward(ViewRootImpl.java:3787) at android.view.ViewRootImpl $ InputStage。應用(ViewRootImpl.java:3669) at android.view.ViewRootImpl $ AsyncInputStage.apply(ViewRootImpl.java:3844) at android.view.ViewRootImpl $ InputStage.deliver(ViewRootImpl.java:3642)android.view.ViewRootImpl $ InputStage.onDeliverToNext(ViewRootImpl.java:3695) at android.view.ViewRootImpl $ InputStage.forward(ViewRootImpl.java:3661) at android.view.ViewRootImpl $ InputStage.apply(ViewRootImpl。 Java的:3669) 在android.view.ViewRootImpl $ InputStage.deliver(ViewRootImpl.java:3642) 在android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922) 在android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl。 java:5896) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857) at android.view.ViewRootImpl $ WindowInputEventReceiver.onInputEvent(ViewRootImpl。的java:6025) 在android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) 在 11月8日至8日:18:36.117 26557-26557/com.example.jzhu26.testui d/AndroidRuntime:關閉VM
任何人都可以幫我嗎?謝謝!