Ale*_*lex 8 fonts android android-ui android-alertdialog
我正在尝试更改AlertDialog邮件的字体大小.
Button submit = (Button) findViewById(R.id.submitButton);
submit.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(
Application1GoodExample.this);
builder.setMessage("Your form has been successfully submitted");
TextView textView = (TextView) findViewById(android.R.id.message);
textView.setTextSize(40);
builder.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
});
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息,指出findViewById()该类型未定义" " AlertDialog.Builder.
Awa*_*Kab 23
用这个 :
AlertDialog alert = builder.create();
alert.show();
TextView msgTxt = (TextView) alert.findViewById(android.R.id.message);
msgTxt.setTextSize(16.0);
Run Code Online (Sandbox Code Playgroud)
在你的情况下:
Button submit = (Button) findViewById(R.id.submitButton);
submit.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(Application1GoodExample.this);
builder.setMessage("Your form has been successfully submitted");
builder.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
// this will solve your error
AlertDialog alert = builder.create();
alert.show();
alert.getWindow().getAttributes();
TextView textView = (TextView) alert.findViewById(android.R.id.message);
textView.setTextSize(40);
Button btn1 = alert.getButton(DialogInterface.BUTTON_NEGATIVE);
btn1.setTextSize(16);
}
});
Run Code Online (Sandbox Code Playgroud)
如果这对您没有帮助,请在您的问题中发布LogCat错误.
| 归档时间: |
|
| 查看次数: |
21585 次 |
| 最近记录: |