My project now is how to make a Snackbar displayed at the bottom of the screen. The Snackbar contain with editText and three button for selection categories. I use LayoutInflat
You have to get id of your Button
. And have to set clickListener
.
You have to just replace your code with this.
I have put listener on btn_mapel
, you can put any other button according to your requirement.
Try this.
@Override
public void onClick(View v) {
CoordinatorLayout linearLayout = (CoordinatorLayout)findViewById(R.id.coordinatorLayout);
final Snackbar snackbar = Snackbar.make(linearLayout, "", Snackbar.LENGTH_INDEFINITE);
Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();
// Inflate your custom view with an Edit Text
LayoutInflater objLayoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View snackView = objLayoutInflater.inflate(R.layout.custom_snac_layout, null);
// custom_snac_layout is your custom xml
Button mapelBt = (Button)snackView.findViewById(R.id.btn_mapel);
mapelBt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Get your button click callback here
}
});
layout.addView(snackView, 0);
snackbar.show();
}