首页 > 系统 > Android > 正文

Android设置个性化Dialog小图标的方法

2019-10-23 20:23:42
字体:
来源:转载
供稿:网友

本文实例讲述了Android设置个性化Dialog小图标的方法。分享给大家供大家参考,具体如下:

设置个性化Dialog小图标,主要代码如下:

@Override  protected void onCreate(Bundle savedInstanceState) {    // Be sure to call the super class.    super.onCreate(savedInstanceState);    requestWindowFeature(Window.FEATURE_LEFT_ICON);    // See assets/res/any/layout/dialog_activity.xml for this    // view layout definition, which is being set here as    // the content of our screen.    setContentView(R.layout.dialog_activity);    getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,        android.R.drawable.ic_dialog_alert);  }

1、申请设置个性化小图标,需在 setContentView(R.layout.dialog_activity) 之前调用:

requestWindowFeature(Window.FEATURE_LEFT_ICON);

2、设置小图标

getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,        android.R.drawable.ic_dialog_alert);

希望本文所述对大家Android程序设计有所帮助。


注:相关教程知识阅读请移步到Android开发频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表