Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to using Toast

Tags:

android

toast

Currently I am developing an episode guide application for a tv show. The basic structure is that the episodes are put into a list, and upon clicking a list item (aka an episode name) the episode description comes up in a Toast.

This generally works fine, however there are situations in which the episode description is too long and one can't read it in the given time.

Are there any alternatives to using a toast in this situation? Thanks for any help.

Edit:

      @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
       //Toast.makeText(this, _details[position], Toast.LENGTH_LONG).show();
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setMessage(this, _details)
             .setCancelable(false)
             .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface dialog, int id) {
                      dialog.cancel();
                 }
             });
  }

(I kept the toast part in there for reference as that was my previous code).

Correct Code

      @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
       //Toast.makeText(this, _details[position], Toast.LENGTH_LONG).show();
      AlertDialog.Builder adb=new AlertDialog.Builder(CurrentActvity.this);
      adb.setTitle("Title");
      adb.setMessage(_details[position]);
      adb.setPositiveButton("Ok", null);
      adb.show();
  }
like image 473
shamsad97 Avatar asked Dec 17 '11 16:12

shamsad97


People also ask

What can be used instead of toast in Android?

Alternatives to using toasts If your app is in the foreground, consider using a snackbar instead of using a toast. Snackbars include user-actionable options, which can provide a better app experience. If your app is in the background, and you want users to take some action, use a notification instead.

What is better clover or toast?

Clover has an analyst rating of 81 and a user sentiment rating of 'great' based on 376 reviews, while Toast has an analyst rating of 86 and a user sentiment rating of 'great' based on 451 reviews.

Does toast work in Mexico?

However, most of the platform's features are only available in the U.S. This means that while restaurants in Canada, the U.K., and Ireland can sign up with Toast, they only have access to limited features and add-ons. TouchBistro has a more global footprint, operating in the U.S., Canada, Mexico, the U.K., and more.


3 Answers

Crouton or SnackBar could be the best choices for you, depending on the exact situation.

like image 193
Tibor Leó Sáfár Avatar answered Oct 14 '22 23:10

Tibor Leó Sáfár


Use Android Dialogs

How to use it, look here!

like image 1
poitroae Avatar answered Oct 14 '22 23:10

poitroae


You can use a Dialog object to present the information or even a custom view would do the job (via the use of a FrameLayout for example).

like image 1
Dimitris Makris Avatar answered Oct 15 '22 00:10

Dimitris Makris