4

I show a Snackbar indefinitely. If the Bluetooth gets turned off, I want to hide it and show a new one to tell the users that they have to turn on the bluetooth. I dismiss the previous Snackbar before showing the new one, but still only the old Snackbar stays visible.

activeSnackbar.dismiss();
Snackbar.make(parent, "Bluetooth is off", Snackbar.LENGTH_INDEFINITE)
            .setAction("Turn on", new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    BluetoothUtil.enableBluetooth(main);
                }
            }).show()

How can I make the old Snackbar disappear before showing the new one?

4

1 回答 1

5

你不必为它做任何特别的事情,只需制作下一个 Snackbar 并显示它,它会使旧的消失而不调用dismiss方法。

于 2016-01-20T20:14:39.787 回答