ECLaboratorio / BubbleShowCase-Android

BubbleShowCase is a framework that let you to use informative bubbles to help your users pointing out different App features.
MIT License
604 stars 90 forks source link

Targetview to menu in Action bar #14

Open Asykur opened 6 years ago

Asykur commented 6 years ago

how i can to set targetview to menu in action bar (right top corner) ?

JorgeCM commented 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.

PranavVyas commented 5 years ago

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

rajam1215 commented 4 years ago

Hello @PranavVyas @JorgeCM

When i use this line in code val view = findViewById(R.id.action_item_id)

It gives same error like above comment. pleas give some solution how to use bubble show case in Action bar menu.

Thanks

naitiksoni92 commented 4 years ago

We can get a view from MenuItem like this. https://stackoverflow.com/a/48047390/4659743