Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the duration of Crouton messages in Android

I have started using Crouton messages instead of toast messages because I could configure the time duration. Is there any way I can keep displaying the crouton message until a particular event rather than specifying the time in definite units?

like image 990
SoulRayder Avatar asked Nov 27 '13 05:11

SoulRayder


1 Answers

You can set the Crouton's duration to INFINITE from within the Configuration. Then add an OnClickListener to it in which you call Crouton.hide(...) like this:

final Crouton crouton = Crouton.makeText(new Activity(), "foo", Style.ALERT)
    .setConfiguration(new Configuration.Builder().setDuration(Configuration.DURATION_INFINITE).build());

crouton.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
    Crouton.hide(crouton);
  }
});

crouton.show();
like image 76
keyboardsurfer Avatar answered Oct 10 '22 02:10

keyboardsurfer