Reputation: 301
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();
}
Upvotes: 6
Views: 20167
Reputation: 81
Crouton or SnackBar could be the best choices for you, depending on the exact situation.
Upvotes: 8
Reputation: 524
Loooking for similar feature, I just found the Android Snackbar. This is a great alternative! http://www.androidhive.info/2015/09/android-material-design-snackbar-example/
Upvotes: 1
Reputation: 168
The open source library Crouton will be a very good choice in this case I believe. You can just give it a try...
Crouton is a class that can be used by Android developers that feel the need for an alternative to the Context insensitive Toast.
This is an open source library and the URL is as follows: https://github.com/keyboardsurfer/Crouton
Upvotes: 1
Reputation: 639
There is a Crouton library that is a Context sensitive alternative to Toast
. It can not be invoked from within the Application class, but from the Activity. Might help you nonetheless.
Upvotes: 0
Reputation: 5183
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).
Upvotes: 1