熟悉android代码的人可能更容易。我是新手......我只是在我的小吃店被解雇后继续采取行动。我阅读了教程here,但仍然没有给我明确的指示。
adapterTutorSubject.setOnClickListener(new AdapterTutorSubject.OnClickListener() {
@Override
public void onItemClick(View view, TutorSubject obj, int pos) {
Snackbar.make(parent_view, "Item " + obj.subjectName + " clicked", Snackbar.LENGTH_SHORT).show();
//On snackbar dismissed, then go to this page
Intent intent = new Intent(getApplicationContext(), ChapterListActivity.class);
startActivity(intent);
}
});
谢谢!
答案 0 :(得分:0)
你可以简单地将setCallback设为here。 修改代码如:
adapterTutorSubject.setOnClickListener(new AdapterTutorSubject.OnClickListener() {
@Override
public void onItemClick(View view, TutorSubject obj, int pos) {
Snackbar snack = Snackbar.make(parent_view, "Item " + obj.subjectName + " clicked", Snackbar.LENGTH_SHORT);
snack.setCallback(new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar snackbar, int event) {
if (event == Snackbar.Callback.DISMISS_EVENT_TIMEOUT) {
// Snackbar closed on its own
}
}
@Override
public void onShown(Snackbar snackbar) {
//Do something in shown
}
});
snack.show();
}
});
希望它有所帮助!!!