Configuración de la duración de los mensajes de Crouton en Android
Frecuentes
Visto 2,492 veces
2 Respuestas
19
You can set the Crouton's duration to INFINITE
desde dentro del Configuration
. Luego agregue un OnClickListener
to it in which you call Crouton.hide(...)
Me gusta esto:
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();
respondido 27 nov., 13:09
1
Instead of using the Crouton library, you can simply add a view
y establecer un onClickListener
to it. When the user click on it, the view
se elimina de la Layout
.
respondido 27 nov., 13:06
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas android crouton or haz tu propia pregunta.
Thank you for your response, but can I call Crouton.hide(crouton) without the on-click listener? I mean to say, can I call just the hide function in an if-branch? - almarayder
One more question, do the crouton variables have to be final? Or can we declare in some way using normal declarations. Because, currently, the show and hide methods give error if I try with non-final crouton variables. - almarayder
To your first question. You can hide the Crouton any way you want. The second question: Yes, it has to be final, if you're trying to access it from an inner class. - Ben Weiss
After declaring the croutons in the way you have in the MainActivity class, I am calling an AsyncTask from which I call the show and hide functions from runOnUiThread in doInbackground() function. I keep getting null pointer exception related to croutons. Please tell me how to rectify this? - almarayder
This is a different question. Please ask it and include the stack trace there. - Ben Weiss