Open Asykur opened 6 years ago
Hi Asykur,
For your case, you only need to get the MenuItem view and send it by 'targetView' function to your BubbleShowCaseBuilder. To get the MenuItem view from your Activity, you have to do the following lines:
val view = findViewById<ActionMenuItemView>(R.id.action_item_id) //where 'action_item_id' is the id of the MenuItem set on your xml menu file.
BubbleShowCaseBuilder(this) //Activity instance
.title("foo") //Any title for the bubble view
.targetView(view) //View to point out
.show() //Display the ShowCase
If you have any problem with this, let me know and I will be glad to help you.
Sorry for the delay.
Hi @JorgeCM , I tried the step you suggested app crashes because of nullPointerException
Here is 👍
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vyas.pranav.studentcompanion/com.vyas.pranav.studentcompanion.ui.activities.SetUpActivity}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter targetView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2951) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6718) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter targetView at com.elconfidencial.bubbleshowcase.BubbleShowCaseBuilder.targetView(Unknown Source:2) at com.vyas.pranav.studentcompanion.ui.activities.SetUpActivity.showInstruction(SetUpActivity.java:73) at com.vyas.pranav.studentcompanion.ui.activities.SetUpActivity.onCreate(SetUpActivity.java:51) at android.app.Activity.performCreate(Activity.java:7144) at android.app.Activity.performCreate(Activity.java:7135) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6718) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I have double checked about Id and it is same, I am using Butterknife to bind Toolbar and then set it as SupportActionBar
Hello @PranavVyas @JorgeCM
When i use this line in code
val view = findViewById
It gives same error like above comment. pleas give some solution how to use bubble show case in Action bar menu.
Thanks
We can get a view from MenuItem like this. https://stackoverflow.com/a/48047390/4659743
how i can to set targetview to menu in action bar (right top corner) ?