我使用默认的Android Alert Dialog来显示2行描述和消息。当我在代码下面运行它在android中的标题文本开头显示ellipsize。
public void showDeleteConfirmationDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.dialog_document_title));
builder.setMessage(getString(R.string.dialog_document_message));
builder.setPositiveButton(R.string.dialog_btn_yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
new Thread(new Runnable() {
@Override
public void run() {
File file;
for (String scanImagePath : scanImageList) {
file = new File(scanImagePath);
if (file.exists()) {
file.delete();
}
}
finish();
}
}).run();
}
});
builder.setNegativeButton(R.string.dialog_btn_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
并在标题上开始ellipsize。 enter image description here
答案 0 :(得分:0)
试试这个
AlertDialog.Builder builder = new AlertDialog.Builder(this);
TextView textView = (TextView) dialog.findViewById(android.R.id.title);
textView.setMaxLines(2);
textView.setText(getString(R.string.dialog_document_title));
builder.setMessage(getString(R.string.dialog_document_message));
builder.setPositiveButton(R.string.dialog_btn_yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
new Thread(new Runnable() {
@Override
public void run() {
File file;
for (String scanImagePath : scanImageList) {
file = new File(scanImagePath);
if (file.exists()) {
file.delete();
}
}
finish();
}
}).run();
}
});
builder.setNegativeButton(R.string.dialog_btn_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
答案 1 :(得分:0)