我正在使用 seekBar 对自定义相机应用程序进行缩放控制。我的应用程序有时会删除 cameraPreview 并在重新添加 cameraPreview 时我想重置我的搜索栏的进度。
public void restartCam() {
//zoomCtrl.setVerticalScrollbarPosition(0x00000000);
camPreview = new CamSurfaceView(this.getApplicationContext(), camFace);
frame.addView(camPreview);
zoomCtrl.setProgress(0);
}
但我得到一个空指针:
12-03 12:18:54.319: E/AndroidRuntime(15805): FATAL EXCEPTION: main
12-03 12:18:54.319: E/AndroidRuntime(15805): java.lang.NullPointerException
12-03 12:18:54.319: E/AndroidRuntime(15805): at com.sapientnitro.lcinstore2.view.CamSurfaceView.zoomTo(CamSurfaceView.java:120)
12-03 12:18:54.319: E/AndroidRuntime(15805): at com.sapientnitro.lcinstore2.activities.CustomCamera.onProgressChanged(CustomCamera.java:643)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:609)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.widget.ProgressBar.refreshProgress(ProgressBar.java:621)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.widget.ProgressBar.setProgress(ProgressBar.java:670)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.widget.ProgressBar.setProgress(ProgressBar.java:651)
12-03 12:18:54.319: E/AndroidRuntime(15805): at com.sapientnitro.lcinstore2.activities.CustomCamera.restartCam(CustomCamera.java:568)
12-03 12:18:54.319: E/AndroidRuntime(15805): at com.sapientnitro.lcinstore2.activities.CustomCamera.cameraOn(CustomCamera.java:435)
12-03 12:18:54.319: E/AndroidRuntime(15805): at com.sapientnitro.lcinstore2.activities.CustomCamera$5.onClick(CustomCamera.java:317)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.view.View.performClick(View.java:3558)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.view.View$PerformClick.run(View.java:14157)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.os.Handler.handleCallback(Handler.java:605)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.os.Handler.dispatchMessage(Handler.java:92)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.os.Looper.loop(Looper.java:137)
12-03 12:18:54.319: E/AndroidRuntime(15805): at android.app.ActivityThread.main(ActivityThread.java:4514)
12-03 12:18:54.319: E/AndroidRuntime(15805): at java.lang.reflect.Method.invokeNative(Native Method)
12-03 12:18:54.319: E/AndroidRuntime(15805): at java.lang.reflect.Method.invoke(Method.java:511)
12-03 12:18:54.319: E/AndroidRuntime(15805): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
12-03 12:18:54.319: E/AndroidRuntime(15805): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
12-03 12:18:54.319: E/AndroidRuntime(15805): at dalvik.system.NativeStart.main(Native Method)
我的进度变化:
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// TODO Auto-generated method stub
if (mode.equals("camera")) {
camPreview.zoomTo(progress);
}
}