在Android开发中,获取Drawable Image名称的方法如下:
<?xml version="1.0" encoding="utf-8"?><resources>
<string name="image_name_1">image_1</string>
<string name="image_name_2">image_2</string>
<string name="image_name_3">image_3</string>
</resources>
Resources.getResourceEntryName()
方法获取Drawable Image的名称。例如,以下代码将获取名为"image_name_1"的Drawable Image的名称:Resources resources = getResources();
int resourceId = R.drawable.image_name_1;
String imageName = resources.getResourceEntryName(resourceId);
Resources.getIdentifier()
方法。例如,以下代码将获取名为"image_name_1"的Drawable Image的ID:Resources resources = getResources();
String imageName = "image_name_1";
int resourceId = resources.getIdentifier(imageName, "drawable", getPackageName());
通过以上方法,您可以在Android开发中获取Drawable Image名称。
领取专属 10元无门槛券
手把手带您无忧上云