This is a sample project demonstrating the use of the Reflective Drawable Loader Library.
The library (and code) can be found here: https://github.com/alt236/Reflective-Drawable-Loader---Android
Project Description
---
Were you ever in a situation where you had to access Drawables based on their names (for example if the Drawable names are stored in a DB) and you had to write long lookup tables converting the names into R.drawable.ids? And maintaining them?
This library is offering a way around it by using reflection to access the Drawable directly by name. You only need to include them as normal into your Res folder tree. It has been benchmarked at up to 5x faster than the platform's Resources.getIdentifier() method.
It is using LRU caching to mitigate the reflection time overhead for both reflection "hits" and "misses".
</div> <div jsname="WJz9Hc" style="display:none">这是一个示例项目演示了如何使用反光绘制对象装载机图书馆。
库(和代码)可以在这里找到:https://github.com/alt236/Reflective-Drawable-Loader---Android
项目介绍
---
在一个情况下,你必须访问可绘制对象的基础上他们的名字(例如,如果绘制对象名称存储在DB)曾经是你的话,你不得不写长长的查找表转换成名称R.drawable.ids?和维护他们?
这个库是通过使用反射来直接通过名称访问可绘制对象提供变通的办法。你只需要把它们作为正常到你的res文件夹树。据基准在高达5倍比平台的Resources.getIdentifier()方法更快。
它使用LRU缓存来减轻反射时间开销为反思“点击”和“失误”。</div> <div class="show-more-end">