2011-11-26 75 views

回答

1

你不能,至少不能直接。欢迎您创建自己的Ant任务,这些任务将生成属性文件或其他任何您想要的字符串资源文件。

0

是的,你可以

下面是使用属性文件在您的项目的解决方案。

1创建Android专案

2编辑该文件夹的资产名为app.properties文件,并在要使用例如,作为

test=success 

和保存文件的属性写

3写这个方法在你的活动课

private Properties loadPropties() throws IOException { 
    String[] fileList = { "app.properties" }; 
    Properties prop = new Properties(); 
    for (int i = fileList.length - 1; i >= 0; i--) { 
    String file = fileList[i]; 
    try { 
     InputStream fileStream = getAssets().open(file); 
     prop.load(fileStream); 
     fileStream.close(); 
    } catch (FileNotFoundException e) { 
     Log.d(TAG, "Ignoring missing property file " + file); 
    } 
    } 
    return prop; 
    } 

4随着onCreate方法写这样

​​3210

5某些东西添加必要的进口

+0

更加好,如果你声明自己的应用程序类将是从那里 – Javanator

+0

做到这一点装和投的getProperty值每需要int或字符串或其他 – Javanator

相关问题