我正在展示一个非常简单的 AlertDialog
使用这个小代码 fragment :
AlertDialog.Builder bldBuilder = new AlertDialog.Builder(WarningActivity.this);
bldBuilder.setMessage(strTrace).setTitle(strTrace.split("\n")[0]);
AlertDialog dlgTrace = bldBuilder.create();
dlgTrace.show();
我的对话框的内容是堆栈跟踪,因此行可能会很长。我想要防止在默认警报对话框中换行,但我似乎无法弄清楚如何。我一直在努力挖掘这个答案,但我一直无法理解如何去做。
最佳答案
您有 2 个可能的选择:第一个是创建您自己的布局。其次是修改默认的 AlertDialog 布局的 textview
//after creating the dialog, get the textview
TextView textView = (TextView) dlgTrace.findViewById(android.R.id.message);
//then set single line to false
textView.setSingleLine(false);
关于java - 如何防止文本在警告对话框中换行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23433779/