字符串转换为可绘制 [英] Convert String to Drawable

查看:170
本文介绍了字符串转换为可绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个通知显示在状态栏中的图标 - 到目前为止好,但实际上我想这个图标是一个3字符串

I want to raise a notification showing an icon in the status bar - so far so good, but actually I would like this icon to be a 3 character String.

所以我的问题是:有没有办法给我的字符串转换为绘制对象在状态栏中显示为图标

So my question is: Is there a way to convert my String into a Drawable to display it as Icon in the status bar?

编辑:最近,我发现了一个应用程序,它有类似的功能 - 电池指示器

I recently found an app which does something similar - Battery Indicator

这显示当前电池电量的状态栏通知图标 - 我不知道它是否真的使用了不同的100张图片

It shows the current battery level as notification icon in the status bar - I wonder if it really uses different 100 images

推荐答案

简称:不,你不能

长:通知需要一个 R.drawable.something 的图标,你不能在运行时创建

Long: The notification needs a R.drawable.something for the icon and you can't create it on runtime.

这篇关于字符串转换为可绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆