I am using ShowcaseView
library from here in my android application. I want use ShowcaseView
with Actionbar Compat
. But i am not getting how to use it? I have tried following code but it throws NullPointerexception
. Please help me solve this issue.
Thank you.
Code :
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);
}
}
Error log:
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)
See this blog post. I am using the support library and it works fine.
The following code will create three views that show back to back (overflow menu, a view in my page, and an action bar item).
I solved that issue.Replace code of
OnCreateOptionsMenu()
with following code.Code: