无法解析方法setShowcaseItem

时间:2015-02-26 02:14:12

标签: slideshow showcaseview

任何人都可以向我解释如何使用showcaseviews类,我已经尝试将它们添加到我的活动中,但是当我尝试添加此类并且它说方法.setShowcaseItem,.setText时我收到错误,.setShowcaseView

/**
 * This class allows you to have multiple showcases on one screen, you can then page through
 * each one as you press the 'ok' button
 */
public class ShowcaseViews {

    private final List<ShowcaseView> views = new ArrayList<ShowcaseView>();
    private final Activity activity;
    private final int showcaseTemplateId;

    private interface OnShowcaseAcknowledged {
        void onShowCaseAcknowledged(ShowcaseView oldView);
    }

    /**
     * @param activity               The activity containing the views you wish to showcase
     * @param showcaseTemplateLayout Must be the layout of a ShowcaseView - use this to style your showcase
     */
    public ShowcaseViews(Activity activity, int showcaseTemplateLayout) {
        this.activity = activity;
        this.showcaseTemplateId = showcaseTemplateLayout;
    }

    public void addView(ItemViewProperties properties) {
        ShowcaseView viewTemplate = newInstanceOfShowcaseView();
        viewTemplate.setShowcaseItem(properties.itemType, properties.id, activity);
        viewTemplate.setText(properties.titleResId, properties.messageResId);
        setChainClickListener(viewTemplate);
        views.add(viewTemplate);
    }

    public void addView(ViewProperties properties) {
        ShowcaseView viewTemplate = newInstanceOfShowcaseView();
        View v = activity.findViewById(properties.id);
        viewTemplate.setShowcaseView(v);
        viewTemplate.setText(properties.titleResId, properties.messageResId);
        setChainClickListener(viewTemplate);
        views.add(viewTemplate);
    }

    private ShowcaseView newInstanceOfShowcaseView() {
        return (ShowcaseView) activity.getLayoutInflater().inflate(showcaseTemplateId, null);
    }

    private void setChainClickListener(final ShowcaseView viewTemplate) {
        viewTemplate.overrideButtonClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                acknowledgedListener.onShowCaseAcknowledged(viewTemplate);
            }
        });
    }

    private OnShowcaseAcknowledged acknowledgedListener = new OnShowcaseAcknowledged() {
        @Override
        public void onShowCaseAcknowledged(ShowcaseView oldView) {
            oldView.hide();
            show();
        }
    };

    /**
     * Showcases will be shown in the order they where added, continuing when the button is pressed
     */
    public void show() {
        if (views.isEmpty()) {
            return;
        }
        final ShowcaseView view = views.get(0);
        ((ViewGroup) activity.getWindow().getDecorView()).addView(view);
        views.remove(0);
    }

    /**
     * Used for views on the ActionBar
     */
    public static class ItemViewProperties extends ViewProperties {
        public static final int ID_SPINNER = 0;
        public static final int ID_TITLE = 0;
        protected final int itemType;

        public ItemViewProperties(int id, int titleResId, int messageResId, int itemType) {
            super(id, titleResId, messageResId);
            this.itemType = itemType;
        }
    }

    /**
     * Used for all views except those on the ActionBar
     */
    public static class ViewProperties {
        protected final int titleResId;
        protected final int messageResId;
        protected final int id;

        public ViewProperties(int id, int titleResId, int messageResId) {
            this.id = id;
            this.titleResId = titleResId;
            this.messageResId = messageResId;
        }
    }

}

0 个答案:

没有答案