我想使用快餐栏,当点击按钮并改变意图并打开新活动时。单击按钮时要显示小吃栏。
答案 0 :(得分:1)
我希望这对您有用。
先显示小吃栏,然后在2秒后打开活动。
snackbar = Snackbar.make(coordinatorLayout, "Please Wait New Page Open", Snackbar.LENGTH_LONG);
snackbar.show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this, YourActivity.class);
startActivity(intent);
}
}, 2000);
答案 1 :(得分:0)
这是方法
/**
* Method for show snackbar with button
* @param parentLayout pass any view where from calling like pass as buttton
* @param message Message which you want to show on snackbar
* @param actionButton Button title or name which you want to display
* @param actionButtonColor specifies your snackbar button color id
*/
public void showSnackBar(View parentLayout, String message, String actionButton, int actionButtonColor) {
if (message != null) {
Snackbar.make(parentLayout, message, Snackbar.LENGTH_LONG)
.setAction(actionButton != null ? actionButton : "Okay", new View.OnClickListener() {
@Override
public void onClick(View view) {
//perform action on snackbar button click
}
})
.setActionTextColor(getResources().getColor(actionButtonColor))
.show();
}
}
方法调用
showSnackBar(button,"Snackbar show","Cancel",R.color.white);
答案 2 :(得分:0)
您想在两次活动之间显示小吃栏。您需要在小吃吧周围包裹一个包装,因为小吃吧需要显示一个视图。
希望此解决方案可以为您https://stackoverflow.com/a/37707741/9734616