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();
}
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.
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.
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.
Crouton or SnackBar could be the best choices for you, depending on the exact situation.
Use Android Dialogs
How to use it, look here!
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With