内容简介:翻译自:https://stackoverflow.com/questions/15362122/change-font-size-for-an-alertdialog-message
参见英文答案 > Changing font size into an AlertDialog 5个
我正在尝试更改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(); } });
我收到一条错误消息,指出AlertDialog.Builder类型的“findViewById()”未定义.
用这个 :
AlertDialog alert = builder.create(); alert.show(); TextView msgTxt = (TextView) alert.findViewById(android.R.id.message); msgTxt.setTextSize(16.0);
在你的情况下:
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); } });
如果这对您没有帮助,请在您的问题中发布LogCat错误.
翻译自:https://stackoverflow.com/questions/15362122/change-font-size-for-an-alertdialog-message
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- html – 更改DIV(CSS)中的字体颜色
- CSS 字体:字体特性
- iOS 自定义字体设置与系统自带的字体
- ReactNative字体大小不随系统字体大小变化而变化
- 再谈中文字体的子集化与动态创建字体
- 可爱气质的中文字体,字体视界法棍体-开源免费下载
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Java语言精粹
Jim Waldo / 王江平 / 电子工业出版社 / 2011-6 / 39.00元
这是一本几乎只讲java优点的书。 Jim Waldo先生是原sun微系统公司实验室的杰出工程师,他亲历并参与了java从技术萌生、发展到崛起的整个过程。在这《java语言精粹》里,jim总结了他所认为的java语言及其环境的诸多精良部分,包括:类型系统、异常处理、包机制、垃圾回收、java虚拟机、javadoc、集合、远程方法调用和并发机制。另外,他还从开发者的角度分析了在java技术周围......一起来看看 《Java语言精粹》 这本书的介绍吧!