multiple showcaseviews android

1.4k views Asked by At

How can I add multiple showcaseviews to my layout... I've tried this:

import com.github.amlcurran.showcaseview.sample.R;

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

public class MultipleShowcaseSampleActivity extends Activity {

    private static final float SHOWCASE_KITTEN_SCALE = 1.2f;
    private static final float SHOWCASE_LIKE_SCALE = 0.5f;
    //ShowcaseViews mViews;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sample_legacy);

        findViewById(R.id.buttonLike).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getApplicationContext(), R.string.like_message, Toast.LENGTH_SHORT).show();
            }
        });

        //mOptions.block = false;
//        mViews = new ShowcaseViews(this,
//                new ShowcaseViews.OnShowcaseAcknowledged() {
//            @Override
//            public void onShowCaseAcknowledged(ShowcaseView showcaseView) {
//                Toast.makeText(MultipleShowcaseSampleActivity.this, R.string.dismissed_message, Toast.LENGTH_SHORT).show();
//            }
//        });
//        mViews.addView( new ShowcaseViews.ItemViewProperties(R.id.image,
//                R.string.showcase_image_title,
//                R.string.showcase_image_message,
//                SHOWCASE_KITTEN_SCALE));
//        mViews.addView( new ShowcaseViews.ItemViewProperties(R.id.buttonLike,
//                R.string.showcase_like_title,
//                R.string.showcase_like_message,
//                SHOWCASE_LIKE_SCALE));
//        mViews.show();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            enableUp();
        }
    }

You can see the comment part, When I uncomment Showcaseview cant found those methods so maybe ShowcaseViews missing, anyway I tried to copy and create that class, but still need methods from showcaseview that cant be found.

Help Me.

Update: Ok according the answer below, I have a problem:

mViews = new ShowcaseView(this,
       new ShowcaseView.setOnShowcaseEventListener() {
    @Override
    public void onShowCaseAcknowledged(ShowcaseView showcaseView) {
        Toast.makeText(MultipleShowcaseSampleActivity.this, R.string.dismissed_message, Toast.LENGTH_SHORT).show();
    }
});
mViews.addView( new ShowcaseView.ItemViewProperties(R.id.image,
        R.string.showcase_image_title,
        R.string.showcase_image_message,
        SHOWCASE_KITTEN_SCALE));
mViews.addView( new ShowcaseView.ItemViewProperties(R.id.buttonLike,
        R.string.showcase_like_title,
        R.string.showcase_like_message,
        SHOWCASE_LIKE_SCALE));
mViews.show();

On new ShowcaseView.setOnShowcaseEventListener() Cannot be resolve to a type then new ShowcaseView.ItemViewProperties Cannot be resolve to a type too.

1

There are 1 answers

6
cjds On

The library doesn't have any class called ShowCaseViews. It only has a class ShowCaseView.

If you are following this github example you have to have the class given in the link

EDIT Okay let me try and explain classes

There are 2 classes

  1. ShowcaseView (in the library)
  2. ShowcaseViews (in the example on Github)

You cannot say ShowcaseView.ItemProperties because ShowcaseView doesn't have them. They belong to ShowcaseViews. Hence they cannot be resolved or found.

OnShowcaseEventListener is a whole different class, contained in neither one of these but just exists separately and hence also when you say ShowcaseView.OnShowcaseEventListener it can't be resolved.

Change ShowcaseView.OnShowcaseEventListener to just OnShowcaseEventListener and ShowcaseView.ItemPropertiesto ShowcaseViews.ItemProperties