这是一个奇怪的案例,最近才引起我的注意。我有一个 Activity 在创建时显示 AlertDialog 以警告用户要完成他们需要重新启动的过程。在我的设备 (Galaxy Nexus) 上,它显示得很好。最近才引起我的注意,在许多其他设备上它只显示几个字就被切断了。
AlertDialog.Builder builder = new AlertDialog.Builder(ReportActivity.this);
builder.setTitle("Finished!");
builder.setMessage("Due to the different storage mediums across the various Android devices this app may eb used for, "
+"I've decided not to force a media rescan because depending on your device, "
+"it may or may not even be possible. "
+"This means that you will need to reboot your device or unmount/mount your sdcard in the Settings app before most players will pull in all the information for the songs."
+"\n Please reboot or rescan before claiming that the app did not work.")
.setCancelable(false)
.setPositiveButton("Dismiss", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
lv1.setAdapter(new ResultsAdapter(ReportActivity.this, results));
}
});
AlertDialog alert = builder.create();
alert.show();
最佳答案
与其使用 setMessage()
,不如尝试 setView()
,提供您自己的 TextView
,您可以在其中控制显示的行数显示。
关于Android AlertDialog 在某些设备上不显示整个 setMessage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9542284/