0

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.

  • Have you added the showcaseview project as a library? Its a github project and needs to be in your libraries before you can run any of its code – cjds Dec 05 '14 at 05:08
  • Yes, I added When I run with single showcaseview its ok but I need multiple showcaseviews, Im using https://github.com/amlcurran/ShowcaseView – Jose Carrasco Dec 05 '14 at 05:10

1 Answers1

0

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

cjds
  • 8,268
  • 10
  • 49
  • 84
  • Ok, here I have a problem: mViews.addView( new ShowcaseView.ItemViewProperties. It shows that no have ItemViewProperties. – Jose Carrasco Dec 05 '14 at 05:22
  • That's a different question I'd recommend you ask it as a separate question and tick this since it has a different concept to it. – cjds Dec 05 '14 at 05:45
  • 1
    please tick the answer if you find it helpful – cjds Dec 05 '14 at 05:56
  • ok I followed that link min ago... but there are three methods missed: setShowcaseItem(), setText() and setShowcase() – Jose Carrasco Dec 05 '14 at 05:58
  • still problem on both situations Ive changed and still cannot resolve to a type. Plus setShowcaseView() , setText() and setShowCase() cannot be found on github library cz is part of the old showcaseview – Jose Carrasco Dec 05 '14 at 06:14
  • Cannot resolve to a type error is very common. It means that it cannot find that class that it is looking for. The above code should work. If it is part of the old showcaseview. Why isn't it part of the new one? – cjds Dec 05 '14 at 13:59