我在我的 android 应用程序中使用这里ShowcaseView
的库。我想与. 但我不知道如何使用它?我尝试过以下代码,但它会抛出. 请帮我解决这个问题。ShowcaseView
Actionbar Compat
NullPointerexception
谢谢你。
代码 :
public class Activity1 extends ActionBarActivity implements
OnShowcaseEventListener {
ShowcaseView sv;
ShowcaseView.ConfigOptions co;
@Override
protected void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen1);
co = new ShowcaseView.ConfigOptions();
co.hideOnClickOutside = false;
co.block = false;
}catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
ActionViewTarget target = new ActionViewTarget(this,
ActionViewTarget.Type.OVERFLOW);
sv = ShowcaseView.insertShowcaseView(target, this, "Edit",
"Click here to edit image.", co);
}
}
错误日志:
11-29 17:12:19.792: E/AndroidRuntime(20991): FATAL EXCEPTION: main
11-29 17:12:19.792: E/AndroidRuntime(20991): java.lang.NullPointerException
11-29 17:12:19.792: E/AndroidRuntime(20991): at com.espian.showcaseview.targets.ViewTarget.getPoint(ViewTarget.java:22)
11-29 17:12:19.792: E/AndroidRuntime(20991): at com.espian.showcaseview.targets.ActionViewTarget.getPoint(ActionViewTarget.java:52)
11-29 17:12:19.792: E/AndroidRuntime(20991): at com.espian.showcaseview.ShowcaseView$3.run(ShowcaseView.java:240)
11-29 17:12:19.792: E/AndroidRuntime(20991): at android.os.Handler.handleCallback(Handler.java:725)
11-29 17:12:19.792: E/AndroidRuntime(20991): at android.os.Handler.dispatchMessage(Handler.java:92)
11-29 17:12:19.792: E/AndroidRuntime(20991): at android.os.Looper.loop(Looper.java:137)
11-29 17:12:19.792: E/AndroidRuntime(20991): at android.app.ActivityThread.main(ActivityThread.java:5283)
11-29 17:12:19.792: E/AndroidRuntime(20991): at java.lang.reflect.Method.invokeNative(Native Method)
11-29 17:12:19.792: E/AndroidRuntime(20991): at java.lang.reflect.Method.invoke(Method.java:511)
11-29 17:12:19.792: E/AndroidRuntime(20991): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
11-29 17:12:19.792: E/AndroidRuntime(20991): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
11-29 17:12:19.792: E/AndroidRuntime(20991): at dalvik.system.NativeStart.main(Native Method)