我有一个标题和图像的alertbuilder:
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.pull);
builder.setIcon(R.drawable.tira_cable);
builder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//actions
}
});
AlertDialog dialog = builder.create();
dialog.show();
我检查了问题不在标题中,是在图像中,因为如果我评论setIcon行它会显示标题。
答案 0 :(得分:1)
使用此片段进行修复!!
new AlertDialog.Builder(getApplicationContext())
.setIcon(android.R.drawable.ic_dialog_info)
.setTitle(getResources().getString(R.string.pull))
.setCancelable(false)
.setMessage("Quistion???")
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
}
})
.setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
}
}).show();
答案 1 :(得分:1)
你必须使用:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getResources().getString(R.string.pull));
builder.setIcon(R.drawable.ic_action_search);
builder.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// actions
}
});
AlertDialog dialog = builder.create();
dialog.show();
Yor Title ll现在显示......