目前我正在开发电视节目的剧集指南应用程序.基本结构是将剧集放入列表中,并且在点击列表项(也称为剧集名称)时,剧集描述出现在Toast中.
这通常可以正常工作,但是在某些情况下,剧集描述太长并且在给定时间内无法阅读.
在这种情况下,有没有其他方法可以使用吐司?谢谢你的帮助.
编辑:
@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();
}
});
}
(我把吐司部分留在那里作为参考,因为那是我以前的代码).
正确的代码
@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();
}
解决方法:
Crouton或SnackBar可能是您的最佳选择,具体取决于具体情况.
标签:android,toast
来源: https://codeday.me/bug/20190726/1540698.html
开发者寻求解决方案,当剧集描述过长时,探讨了如何在Android应用中用AlertDialog替换Toast,如Crouton或SnackBar,以提供更好的用户体验。

2062

被折叠的 条评论
为什么被折叠?



