Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 动态创建可绘制资源路径_Android - Fatal编程技术网

Android 动态创建可绘制资源路径

Android 动态创建可绘制资源路径,android,Android,我有如下代码行: Notification notif = new Notification(R.drawable.notification_XX, "Notify", System.currentTimeMillis()); 我的问题是我想使R.drawable.notification_XX可更改,例如,如果我有一个变量i=24然后应使用适当的资源R.drawable.notification\u 24 那么,有没有一种动态创建可绘制资源路径的方法 提前感谢,Martin如果您想更改通知以

我有如下代码行:

Notification notif = new Notification(R.drawable.notification_XX, "Notify", System.currentTimeMillis());
我的问题是我想使
R.drawable.notification_XX
可更改,例如,如果我有一个变量
i=24然后应使用适当的资源
R.drawable.notification\u 24

那么,有没有一种动态创建可绘制资源路径的方法


提前感谢,Martin如果您想更改通知以显示一个您可以设置的数字,则相应的数字将覆盖在通知栏中的图标上

但是,如果您确实有许多不同的图标,则可以使用,它将返回给定名称的资源ID。

getIdentifier()方法在我的情况下非常有效-非常感谢!