Giter Club home page Giter Club logo

Comments (10)

xiphirx avatar xiphirx commented on May 12, 2024

Have you tried targeting MenuITem.getActionView() ?

from taptargetview.

squarenotch avatar squarenotch commented on May 12, 2024

@xiphirx Yes with TapTarget.forView, in onPrepareOptionsMenu, this method returns null. Possibly because it has just been inflated?

from taptargetview.

xiphirx avatar xiphirx commented on May 12, 2024

TapTarget.forToolbarMenuItem(...) Should work fine. Are you sure you're setting an ID for the item and that it exists at the time you're trying to target it?

from taptargetview.

squarenotch avatar squarenotch commented on May 12, 2024

The menu is inflated in CreateOptionsMenu and after some changes to the items I am calling TapTarget.forToolbarMenuItem(toolbar, R.id.menu_mymenuitem.... etc) - This always resolves to null.

I took a look at the toolbar variable and although the MenuItem is in the mItems collection, it is not in the mActionItems collection. I am guessing but its either because it has been added by the fragment or that the item is not fully added to the toolbar in the onPrepareOptionsMenu method?

You see my reason for simply being able to supply a menuitem object :) (banging head on wall)

from taptargetview.

xiphirx avatar xiphirx commented on May 12, 2024

Supplying a MenuItem does the library no good if getActionView is returning null. The library currently requires a view to target.

Could you possible provide a minimal code sample that would replicate this? I can take a further look afterwards

from taptargetview.

squarenotch avatar squarenotch commented on May 12, 2024

` @OverRide
public void onPrepareOptionsMenu(Menu menu) {

    mShowSubscribedOnlyMenuItem = menu.findItem(R.id.menu_showsubscriptiononly);


    Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);

    TapTargetView.showFor(getActivity(),                 // `this` is an Activity
            TapTarget.forToolbarMenuItem(toolbar, R.id.menu_showsubscriptiononly, getText(R.string.taptarget_subscribeview_title), getText(R.string.taptarget_subscribeview_description))
                    // All options below are optional
                    .outerCircleColor(R.color.colorPrimary)      // Specify a color for the outer circle
                    .targetCircleColor(R.color.white)   // Specify a color for the target circle
                    .titleTextSize(30)                  // Specify the size (in sp) of the title text
                    .titleTextColor(R.color.white)      // Specify the color of the title text
                    .descriptionTextSize(20)            // Specify the size (in sp) of the description text
                    .descriptionTextColor(R.color.white)  // Specify the color of the description text
                    .textColor(R.color.white)            // Specify a color for both the title and description text
                    .dimColor(R.color.white)            // If set, will dim behind the view with 30% opacity of the given color
                    .drawShadow(true)                   // Whether to draw a drop shadow or not
                    .cancelable(true)                  // Whether tapping outside the outer circle dismisses the view
                    .tintTarget(true)                   // Whether to tint the target view's color
                    .transparentTarget(false),        // Specify whether the target is transparent (displays the content underneath)
            //.icon(Drawable),                    // Specify a custom drawable to draw as the target
            new TapTargetView.Listener() {          // The listener can listen for regular clicks, long clicks or cancels` etc...

from taptargetview.

squarenotch avatar squarenotch commented on May 12, 2024

@xiphirx Apologies, this seems to be an issue with the menu element itself. It seems an actionViewClass is needed for the method getActionView to work. The library is now working with forView(MenuItemCompat.getActionView(MenuItem)

Thank you

from taptargetview.

squarenotch avatar squarenotch commented on May 12, 2024

@xiphirx It is worth noting however that this seems to introduce a problem as only menu items with an ActionViewClass will work. This is fine for something like a search action but for a standard menu item, im at a total loss. Appreciate the work.

from taptargetview.

xiphirx avatar xiphirx commented on May 12, 2024

I'm skeptical that is actually the case. It seems like something else is going on since the sample app utilizes the forToolbarMenuItem function without issue.

from taptargetview.

squarenotch avatar squarenotch commented on May 12, 2024

@xiphirx I have used that function as per the sample app without a problem. The sample app calls this in onCreate within an activity. I am calling in the onPrepareOptionsMenu within a fragment as the visibility is changing there. I will dive further.

from taptargetview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.