Java 如何使用Android中的ShowcaseView在ListView中定位元素?
我使用Java 如何使用Android中的ShowcaseView在ListView中定位元素?,java,android,listview,showcaseview,Java,Android,Listview,Showcaseview,我使用ShowcaseView将操作栏中的项目作为目标,但无法将列表视图的元素作为目标!我试过了,但没用: ShowcaseView sv = new ShowcaseView.Builder(this,true) .setTarget(new ViewTarget(lv.getChildAt(1).findViewById(R.id.heart))) // Here is where you supply the id of the action bar item you
ShowcaseView
将操作栏中的项目作为目标,但无法将列表视图的元素作为目标!我试过了,但没用:
ShowcaseView sv = new ShowcaseView.Builder(this,true)
.setTarget(new ViewTarget(lv.getChildAt(1).findViewById(R.id.heart)))
// Here is where you supply the id of the action bar item you
// want to display
.setContentTitle("Heart")
.setContentText("Check the venues of your city")
.hideOnTouchOutside()
.build();
很简单。在ViewHolder
中获取元素,然后将用于显示showcase视图的代码放置在bindView
中
不要忘记为列表中的每个元素添加不同的ID。
所以你可以试试这样的
public class ViewHolder extends RecyclerView.ViewHolder {
private TextView button;
public ViewHolder(final View itemView) {
super(itemView);
button = (Button) itemView.findViewById(R.id.list_button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new MaterialShowcaseView.Builder(getActivity())
.setTarget(verifyButton)
.setDismissText("GOT IT")
.setContentText("Your text goes here")
.setDelay(100) // optional but starting animations immediately in onCreate can make them choppy
.singleUse(id + " define an unique id for each item of the list") // provide a unique ID used to ensure it is only shown once
.show();
}
});
}
}
}
要获得更多信息,您可以