WEB开发网
开发学院手机开发Android 开发 分享一个android的工具类(扩充根据R类中的id寻址... 阅读

分享一个android的工具类(扩充根据R类中的id寻址xml)

 2010-11-05 00:56:48 来源:WEB开发网   
核心提示:StringTokenizer st=new StringTokenizer(fileNameLikse,",| ");while(st.hasMoreElements()){if(!filedName.contains(st.nextElement().toString())){continue

StringTokenizer st=new StringTokenizer(fileNameLikse,",| ");

while(st.hasMoreElements()){

if(!filedName.contains(st.nextElement().toString())){

continue LOODFILED;

}

}

result.add(fileds[i].getInt(innerClass));

System.out.println(filedName);

}else{//或

StringTokenizer st=new StringTokenizer(fileNameLikse,",| ");

while(st.hasMoreElements()){

if(filedName.contains(st.nextElement().toString())){

result.add(fileds[i].getInt(innerClass));

System.out.println(filedName);

continue LOODFILED;

}

}

}

}

return result.toArray(new Integer[0]);

}

public static void main(String[] args){

Integer[] ii=null;

try {

ii = ReadR.readId(R.drawable.class,"d,r",true);

} catch (IllegalArgumentException e) {

e.printStackTrace();

} catch (IllegalAccessException e) {

e.printStackTrace();

}

if(ii!=null){

for (int i = 0; i < ii.length; i++) {

System.out.println(ii[i]);

}

}

}

}

package lidongbo.util;

import java.lang.reflect.Field;

import java.util.ArrayList;

import java.util.List;

import java.util.StringTokenizer;

import lidongbo.test.R;

import lidongbo.test.R.drawable;

/**

*

* @author lidongbo

*

*/

public class ReadR {

public static Integer[] readId(Class innerClass) throws IllegalArgumentException, IllegalAccessException {

List result=new ArrayList();

Field[] fileds = innerClass.getDeclaredFields();

for (int i = 0; i < fileds.length; i++) {

result.add(fileds[i].getInt(innerClass));

上一页  1 2 3 4 5 6 7  下一页

Tags:分享 一个 android

编辑录入:coldstar [复制链接] [打 印]
赞助商链接