1 final FloatingActionButton faBtn = (FloatingActionButton) this.findViewById(R.id.faBtn); 2 faBtn.setOnClickListener(new View.OnClickListener() { 3 @Override 4 public void onClick(View v) { 5 final Snackbar snackbar = Snackbar.make(faBtn, "你点击按钮", Snackbar.LENGTH_LONG); 6 snackbar.show(); 7 snackbar.setAction("知道了", new View.OnClickListener() { 8 @Override 9 public void onClick(View v) {10 snackbar.dismiss();11 }12 });13 }14 });