BubbleShowCase-Android icon indicating copy to clipboard operation
BubbleShowCase-Android copied to clipboard

Targetview to menu in Action bar

Open Asykur opened this issue 6 years ago • 4 comments

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

Asykur avatar Nov 05 '18 03:11 Asykur

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.

JorgeCM avatar Nov 14 '18 12:11 JorgeCM

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

PranavVyas avatar Jul 24 '19 14:07 PranavVyas

Hello @PranavVyas @JorgeCM

When i use this line in code val view = findViewById<ActionMenuItemView>(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

rajam1215 avatar Mar 06 '20 07:03 rajam1215

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

naitiksoni92 avatar Sep 17 '20 13:09 naitiksoni92