4

How can ShowcaseView (library) be used with GridView or ListView?

The library is https://github.com/amlcurran/ShowcaseView

user3544087
  • 49
  • 1
  • 3

3 Answers3

8

For those who have the same problem, I just found a great solution :

showcaseView = new ShowcaseView.Builder(getActivity(),true)
    .setTarget(new ViewTarget(myListView.getChildAt(0).findViewById(R.id.itemIcon)))
    .setStyle(R.style.CustomShowcaseTheme)
    .setContentTitle("My test")
    .setContentText("I love fries")
    .setOnClickListener(new View.OnClickListener() {
         ...
     }

Well, you get the element you want with getChildAt(0) and just do a findViewById on it !

Don't need to create any other views !

psv
  • 3,147
  • 5
  • 32
  • 67
2

You can try something like this:

in your layout you can have an invisible button over element you want show

<Button
    android:id="@+id/showcase_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="140dp"
    android:visibility="invisible"
    android:text="Showcase" />

and then simply set that element as a target

ViewTarget target = new ViewTarget(R.id.showcase_button, this);

new ShowcaseView.Builder(this)
                .setTarget(target)
                .setContentTitle("Choose smthn")
                .setContentText("Some other information can be here.")
                .hideOnTouchOutside()
                .build();
0

And when using in fragments, especially for ListViews, you should use it like this :

fragmentView.post(new Runnable() {
        @Override
        public void run() {
        final View listViewIdentity = infoListView.getChildAt(0);
            new GuideView.Builder(getContext())
                    .setTitle("Deneme")
                    .setContentText("Deneme 1 2")
                    .setTargetView(listViewIdentity)
                    .setDismissType(GuideView.DismissType.outside)
                    .build()
                    .show();
        }
    });

Because you have to write this block in onCreate method and when the fragmentView is created the ListView might not be ready.

And this code block gets a specific cell and uses showcase view on it.

The GuideView here is from a library you can find in : android-arsenal library.

I hope this helps as it helped me a lot.

tekin beyaz
  • 105
  • 1
  • 8