Java 开始新意图ShowcaseView按钮单击

Java 开始新意图ShowcaseView按钮单击,java,android,showcaseview,Java,Android,Showcaseview,如果用户在我的Android应用程序教程(ShowcaseView)中按下一个按钮,我不知道如何开始一个新的意图。这是我的ShowcaseView课程: public class ShowcaseViews { private final List<ShowcaseView> views = new ArrayList<ShowcaseView>(); private final Activity activity; private final int showcase

如果用户在我的Android应用程序教程(ShowcaseView)中按下一个按钮,我不知道如何开始一个新的意图。这是我的ShowcaseView课程:

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;
    }
}

}
以下是我的view_showcase XML文件:

<?xml version="1.0" encoding="utf-8"?>
<!-- This is our ShowCase template that we will use
  whenever we want to showcase an item.
  Here we can customise the colors of the showcase. -->
<com.rohit.ShowcaseView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:showcaseview="http://schemas.android.com/apk/res/com.rohit"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
showcaseview:sv_backgroundColor="@color/showcase_background"
showcaseview:sv_buttonText="@string/showcase_button_ok" />


如果我在MainActivity类中的
views.show()
之后添加
startActivity(intent)
,它甚至不会显示对话框,而是直接进入intent。我想在用户单击按钮后打开活动。我不知道该怎么办。如果您想在用户单击按钮后打开活动,则
startActivity(intent)
应该位于
onClick()
方法中,与
views.show()
方法分开。这样,在单击按钮之前不会触发意图。

您应该显示更多的
main活动
类。嘿,您能给我举个例子吗?我是一个初学者,所以我不知道你在说什么。你能编辑你的代码来显示你的主要活动吗?那真的会帮助我帮助你。(顺便说一句,我也是新来的)嘿,我找到了!我只需要创建一个onClick方法,仅此而已!太好了,编码快乐。
<?xml version="1.0" encoding="utf-8"?>
<!-- This is our ShowCase template that we will use
  whenever we want to showcase an item.
  Here we can customise the colors of the showcase. -->
<com.rohit.ShowcaseView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:showcaseview="http://schemas.android.com/apk/res/com.rohit"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
showcaseview:sv_backgroundColor="@color/showcase_background"
showcaseview:sv_buttonText="@string/showcase_button_ok" />