简体   繁体   中英

Android: how to make string-array to be a reference to another string-array?

I can make string to be a reference to another string just like that:

<resources>  
    <string name="my_string">My String</string>  
    <string name="my_alias">@string/my_string</string>  
</resources>  

And i tried to make string-array reference the same way:

<string-array name="my_string_array">
   <item>1</item>
   <item>2</item>
   <item>3</item>
</string-array>

<string-array name="my_string_array_alias">@array/my_string_array</string-array>

But this does not work, unfortunately. I tried to use this array and alias in ListPreference :

<ListPreference
   android:key="my_key"
   android:title="@string/my_title"
   android:entries="@array/my_string_array_alias"
   android:entryValues="@array/my_string_array"
   android:dialogTitle="@string/my_dialog_title" />

and entries is just an empty array. Of course, i can make both entries and entryValues to take the same array, but i like it to be a different ones.

Found this on the Android dev site .

Note: Not all resources offer a mechanism by which you can create an alias to another resource. In particular, animation, menu, raw, and other unspecified resources in the xml/ directory do not offer this feature.

It's a little vague but I believe this means the framework doesn't support it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM