Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ShowcaseView with gestures

I'm using the great ShowcaseView library in my project. Along with that I'm also using this awesome wrapper class ShowcaseViewExample to show the views one after the other.

This works great but I'm lost as to how to use gestures.

Code so far:

 public void showcaseMainActivity() {
          views = new ShowcaseViews(this, R.layout.showcase_view_template);
          views.addView(new ShowcaseViews.ItemViewProperties(R.id.some_menu, R.string.showcase_title, R.string.showcase_message, ShowcaseView.ITEM_ACTION_ITEM));
          views.addView(new ShowcaseViews.ViewProperties(R.id.showcaseButton, R.string.showcase_title, R.string.showcase_message));
          views.show();
        }

Where do I add the code to use gestures for the showcaseButton?

like image 691
input Avatar asked May 07 '26 21:05

input


2 Answers

I'm not the one to answer your question, I'm more of a fellow user who had to do it in what I suspect is the wrong way.

So far I've only focused on making the gesture's work. I don't know how to choose the size of the circles

I wanted to use it the same way you do, but it didn't get me anywhere because I didn't find out where to put the gesture in the line where I added the view. So I did it my way.

Like this:

First I defined the showcaseview:

Fragment thisFrag;
ShowcaseView sv;
ShowcaseView.ConfigOptions co;

And in my oncreate I have this:

co = new ShowcaseView.ConfigOptions();
thisFrag = this;

Then I called this function when I wanted the showcase to be viewed:

public static void showShowcase() {
    // TODO Auto-generated method stub

    co.hideOnClickOutside = false;
    co.showcaseId = 1;
    sv = ShowcaseView.insertShowcaseView(R.id.scrollView1, thisFrag.getActivity(), "Some funny text", " Smaller and funnier text ", co);
    sv.animateGesture(200, 500, 200, 0);

    OnShowcaseEventListener OSEvListner = new OnShowcaseEventListener() {
        public void onShowcaseViewHide(ShowcaseView showcaseView) {
            switch (co.showcaseId) {
            case 1:
                co.showcaseId = 2;
                sv = ShowcaseView.insertShowcaseView(R.id.scrollView2, thisFrag.getActivity(), "How to scroll down", " ", co);
                sv.setOnShowcaseEventListener(this);
                sv.animateGesture(200, 500, 200, 0);
                break;
            case 2:
                co.showcaseId = 3;
                sv = ShowcaseView.insertShowcaseView(R.id.scrollView3, thisFrag.getActivity(),
                        "Do this to change tabs", "", co);
                sv.setOnShowcaseEventListener(this);
                 sv.animateGesture(200, 500, 500, 500);
                break;
            case 3:
                Main.switchTab(1);
                OtherFragment.showShowcase();
        }
        }

        @Override
        public void onShowcaseViewShow(ShowcaseView showcaseView) {
            // TODO Auto-generated method stub

        }
    };

    sv.setOnShowcaseEventListener(OSEvListner);


}   

Hope there is a better way of doing this.

like image 81
LordMarty Avatar answered May 10 '26 11:05

LordMarty


Use the method overrideButtonClick in following sample:

ShowcaseView showcaseView = ShowcaseView.insertShowcaseView(new ViewTarget(yourView), activity, "this is title", "this is detail");

showcaseView.overrideButtonClick(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    //your onClick code
                }
});
like image 20
Mohammad Reza Norouzi Avatar answered May 10 '26 10:05

Mohammad Reza Norouzi