通过反射的方式来更改dialog中文字大小、颜色
来源:互联网 发布:法兰绒衬衫怎么洗 知乎 编辑:程序博客网 时间:2024/05/27 12:21
private AlertDialog normalDialog;
private void showNormalDialog() { /* @setIcon 设置对话框图标 * @setTitle 设置对话框标题 * @setMessage 设置对话框消息提示 * setXXX方法返回Dialog对象,因此可以链式设置属性 */ if (normalDialog == null) { normalDialog = new AlertDialog.Builder(SceneListActivity.this).setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //...To-do } }).setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //...To-do } }).create(); } normalDialog.setCancelable(false); normalDialog.setTitle("提示"); normalDialog.setMessage("你确定要退出吗?"); // 显示 normalDialog.show(); normalDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE).setTextSize(20); normalDialog.getButton(android.app.AlertDialog.BUTTON_NEGATIVE).setTextSize(20); try { //通过反射的方式来更改dialog中文字大小、颜色 Field mAlert = AlertDialog.class.getDeclaredField("mAlert"); mAlert.setAccessible(true); Object mAlertController = mAlert.get(normalDialog); Field mMessage = mAlertController.getClass().getDeclaredField("mMessageView"); mMessage.setAccessible(true); TextView mMessageView = (TextView) mMessage.get(mAlertController); mMessageView.setTextSize(23);mMessageView.setTextColor(Color.RED);Field mTitle = mAlertController.getClass().getDeclaredField("mTitleView"); mTitle.setAccessible(true); TextView mTitleView = (TextView) mTitle.get(mAlertController); mTitleView.setTextSize(20);mTitleView.setTextColor(Color.RED);} catch (IllegalAccessException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); }}
阅读全文
0 0
- 通过反射的方式来更改dialog中文字大小、颜色
- iOS 设置Label中特定的文字大小和颜色
- MFC中改变编辑框文字大小、颜色的方法
- iOS 更改webView文字颜色丶文字大小丶背景色的方法
- iOS 更改webView文字颜色丶文字大小丶背景色的方法
- Android中通过反射来设置Toast的显示时间
- Android中通过反射来设置Toast的显示时间
- Titanium中通过theme来修改TextField hintText的颜色
- 通过代码动态更改progressbar的颜色
- eclipse更改xml文字大小的方法
- eclipse更改不同类型文件的文字大小
- windows mobile 6.0系统中自己制作的今日插件,通过“开始-设置-系统-屏幕-文字大小”调整文字大小后,插件上的文字大小不改变!
- 通过反射方式来调用某个对象的方法的步骤
- android webview 更改显示的分辨率,单独更改文字大小2.
- 不要通过html中font标签的size属性来更改文字的精确大小
- 利用反射来更改Android原生DatePicker文字与分割线颜色
- Android ListDialog 通过反射修改单选dialog的布局
- iOS_UIWebView背景颜色、文字颜色、文字大小的改变
- 图像金字塔 上采样 降采样
- vim命令
- Spring中常用的hql查询方法 (getHibernateTemplate())
- RT-Rthread的目录介绍
- 快点说小程序开发详解
- 通过反射的方式来更改dialog中文字大小、颜色
- C调用LUA创建一个简单的LUA解释器
- JRebel + IDEA开启热部署
- AC自动机
- Matlab Robotic Toolbox工具箱学习笔记(一)
- PCM数据格式(转)
- Docker实战:Docker安装部署RabbitMQ
- 记:使用Wampserver运行php程序时在该局域网的手机访问提示You don't have permission to access / on this server.
- java web 项目中的时间处理