每个资源的名称进行比较的SQLite数据库的一个变量的内容 [英] Compare names of every resource with the content of a variable of sqlite database

查看:126
本文介绍了每个资源的名称进行比较的SQLite数据库的一个变量的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望你能帮助我,我已经研究了我的情况,但没有找到一个很好的答案。我想比较与现有的一切资源名称的变量的内容(如果可能的话只能用绘制资源)。

在短期的问题:如何将一个变量的字符串内容的所有资源的名称,preferential只可绘制资源的列表比较?或者换句话说:如何获得(含字符串)的所有资​​源名称,preferential只绘制资源

列表?

为例: 我想显示基于给定类型的一个象征。这种类型的从SQLite数据库检索。有一个绘制资源存储的很多符号,它们都被命名为喜欢上的可能的类型。对于数据库中的每一个存储型我要显​​示在列表中的配件标志。在平等,应找出通过比较(通过contains方法)变量类型和包含的所有(绘制)资源名称的列表之间。

例: 在数据库中的是名为A,B和C的类型。在绘制资源文件夹中的图形名称为A,BX和S。比较应导致的情况下,在列表中唯一的A型的装修绘制符号A相连。型B和C有没有可能命名为绘制资源,因此应该不会显示任何符号。

我希望你明白我的问题,感谢您在高级的帮助。

解决方案
  

或者换句话说:如何获得(包含字符串)全部列表   资源名称,preferential只绘制资源?

这可能是你想要的:

 字段[]字段= R.drawable.class.getFields();
的String [] allDrawablesNames =新的String [fields.length]
的for(int i = 0; I< fields.length;我++){
    allDrawablesNames [i] =领域[I] .getName();
}
 

I hope you can help me, I already researched my case but didn't found a good answer. I want to compare the content of a variable with the names of all existing resources (if possible only with drawable resources).

The question in short: How to compare the String content of an variable with a list of all resource names, preferential only with drawable resources? Or in other words: How to get a list (containing Strings) of all resource names, preferential only drawable resources?

The Case: I want to display a symbol based on a given type. This type is retrieved from a SQLite Database. There are many symbols stored as a drawable resource, they all are named like on of the possible types. For every stored type in the database I want to display the fitting symbol in a list. The equality should be find out through a comparison (via the contains method) between the variable "type" and a list containing the names of all (drawable) resources.

Example: In the database are types named "A", "B" and "C". In the drawable resources folder are graphics with the name "A", "BX" and "S". The comparison should lead to the case, that in the list only type "A" is connected with the fitting drawable symbol "A". Type "B" and "C" have no likely named drawable resources and thus shouldn't display any symbol.

I hope you understood my question and thank you in advanced for your help.

解决方案

Or in other words: How to get a list (containing Strings) of all resource names, preferential only drawable resources?

This is probably what you want:

Field[] fields = R.drawable.class.getFields();
String[] allDrawablesNames = new String[fields.length];
for (int  i =0; i < fields.length; i++) {           
    allDrawablesNames[i] = fields[i].getName();
}

这篇关于每个资源的名称进行比较的SQLite数据库的一个变量的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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