how to get a multiline alert title on Android
Is there a way to get more than the 2 lines for the Alert title in an AlertDialog
?
I only find "creating a custom dialog" as a possible solution.
Ideally however, one could just set an attribute
- but I can't find any.
EDIT:
AlertDialog alertDialog = new AlertDialog.Builder(AlertAndCallUtility.this).create();
alertDialog.setTitle(getString(R.string.alert_title));
alertDialog.setMessage(getString(R.string.alert_msg));
alertDialog.setButton(getString(R.string.alert_OK),
new DialogInterface.OnClickListener() {
public void onC开发者_开发技巧lick(DialogInterface dialog, int which) {
finish();
}});
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
and xml
<string name="alert_OK">OK:</string>
<string name="alert_title">Please correct your input, parameters are missing.</string>
<string name="alert_msg">Please enter them in the EXTRA tab.</string>
as mentioned, inserting a \n right before "..missing", just cuts it off and one only sees the first two lines until "are" of the title.
You need to use AlertDialog.Builder().setCustomTitle():
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
TextView textView = new TextView(context);
textView.setText("your very long title here");
dialogBuilder.setCustomTitle(textView);
This is a long-shot, but have you tried using \n
in your title for force a newline?
精彩评论