Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ShowcaseView with GridView or ListView

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

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

like image 489
user3544087 Avatar asked Dec 25 '22 10:12

user3544087


2 Answers

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 !

like image 151
psv Avatar answered Jan 09 '23 10:01

psv


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();
like image 38
nick.climciuc Avatar answered Jan 09 '23 11:01

nick.climciuc