Ale*_*lex 0 fonts alert android message dialog
当我按下"提交"按钮时,我正在尝试显示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(android.R.id.message)
我在XML文件中定义了TextView,如下所示:
<TextView android:id="@+id/message"
android:layout_width="285dp"
android:layout_height="78dp"
android:textColor="#000000"
android:textSize="45sp"
android:gravity="center"
/>
Run Code Online (Sandbox Code Playgroud)
我只想更改默认的AlertDialog消息"您的表单已成功提交"字体大小,但是当我按下"提交"按钮时我的程序崩溃了
小智 6
你试图访问android.R,只需删除"android"它应该工作(你的资源在com.yourproject.R,而不是android.R).
findViewById(android.R.id.message)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
242 次 |
| 最近记录: |