在Eclipse/Android中使用strings.xml中的变量
我需要将此标题设置为所选日期的变量只需尝试以下代码即可从项目资源中获取字符串:在Eclipse/Android中使用strings.xml中的变量,android,xml,eclipse,variables,Android,Xml,Eclipse,Variables,我需要将此标题设置为所选日期的变量只需尝试以下代码即可从项目资源中获取字符串: <item android:id="@+id/menu_selectDate" android:orderInCategory="100" android:showAsAction="ifRoom|withText" android:title="@string/date"/> 只需尝试以下代码即可从项目资源获取字符串: <item android:i
<item
android:id="@+id/menu_selectDate"
android:orderInCategory="100"
android:showAsAction="ifRoom|withText"
android:title="@string/date"/>
只需尝试以下代码即可从项目资源获取字符串:
<item
android:id="@+id/menu_selectDate"
android:orderInCategory="100"
android:showAsAction="ifRoom|withText"
android:title="@string/date"/>
试试这个
如果它是字符串数组,则使用
String date= getApplicationContext().getResources().getString(R.string.date);
否则
String[] some_array = getResources().getStringArray(R.array.your_string_array);
试试这个
如果它是字符串数组,则使用
String date= getApplicationContext().getResources().getString(R.string.date);
否则
String[] some_array = getResources().getStringArray(R.array.your_string_array);
这样试试
String date= getApplicationContext().getResources().getString(R.string.date);
请参阅《android开发者指南》尝试这种方式
String date= getApplicationContext().getResources().getString(R.string.date);
请参阅《android开发者指南》在布局中将字符串名称字段留空。然后在活动中写下以下内容:
String res_date = Context.getResources().getString (R.string.date)
将布局中的字符串名称字段保留为空。然后在活动中写下以下内容:
String res_date = Context.getResources().getString (R.string.date)
我在另一个类中设置了日期,我想在strings.xml文件中使用它在Android菜单中使用。我在另一个类中设置了日期,我想在strings.xml文件中使用它在Android菜单中使用。所以我把string.xml保留为空?所以我把string.xml留空了?您在其他类中使用“假设我有一个变量字符串”date是什么意思,我可以在strings.xml文件中使用它吗?变量“date”和资源“date”没有任何共同之处。在其他类中,“假设我有一个变量字符串“date”是什么意思,我可以在strings.xml文件中使用它吗?”?变量“date”和资源“date”没有任何共同之处。