How to Create Snackbar in Sketchware using Androidx

The code used is:

//default button value

String ButtonText = "OK";

//Custom button text

ButtonText = _buttonText;

//Snackbar code

ViewGroup parentLayout = (ViewGroup) ((ViewGroup) this .findViewById(android.R.id.content)).getChildAt(0);

com.google.android.material.snackbar.Snackbar snackbar =
com.google.android.material.snackbar.Snackbar.make(parentLayout, _message, com.google.android.material.snackbar.Snackbar.LENGTH_INDEFINITE).setAction(ButtonText, new View.OnClickListener() {

 @Override
public void onClick(View view) {

}
});

//Setting duration

snackbar.setDuration((int)_duration*1000);

//Snackbar show

snackbar.show();

The tutorial video for this is:


Comments

Popular posts from this blog

How to Create Material Ripple Effect in Sketchware

How to Create Custom Notifications with Listeners

How to create Custom Dialog in Sketchware