android-resources

Get all string resources from XML resource file?

左心房为你撑大大i 提交于 2019-12-04 16:48:18
I have a resource file called suggestions.xml which is translated to a couple of languages. These XML files contain just <string> values. Now, I'd like to retrieve all the strings in the current locale's suggestions.xml file. How do I do that? I know I can retrieve single strings by their ID's, but I'd like to get all the strings in the XML file instead. I wonder why would you need to do this. Still, you can use the generated R class to iterate over all kinds of resources. Field[] fields = R.string.class.getFields(); String[] stringNames = new String[fields.length]; for (int i = 0; i < fields

Different resources for WVGA800 and WVGA854?

跟風遠走 提交于 2019-12-04 16:01:55
Got this really stupid problem: Can find the proper name for the android folder for WVGA800 resources. I've created a folder for WVGA854: drawable-normal-long-hdpi It worked totally fine. For WVGA800 I've tried 'drawable-normal-notlong-hdpi' - emulator and handset still gets resources from 'drawable', not even 'drawable-normal-long-hdpi'. Tried using 'drawble-hdpi', 'drawable-notlong-hdpi' - nothing works, it keeps using 'drawable' for resources. How should the folder for WVGA800 be named? UPD: Using supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens=

Format string XXX is not a valid format string so it should not be passed to String.format

南楼画角 提交于 2019-12-04 15:32:23
问题 I have android app and this string in resources: <string name="create_group_select_people">Select up to %1$d people!</string> This is called from fragment: Integer countMax = 5; //also tried just "int" - nothing changed getResources().getString(R.string.create_group_select_people, countMax); but I got error: Format string 'create_group_select_people' is not a valid format string so it should not be passed to String.format I can't understand what is wrong? When I launch app - it shows me

Best way to store Resource id in Database on Android

浪子不回头ぞ 提交于 2019-12-04 14:49:13
问题 In my app i want to be able to store resource id of some icons in database. I suppose it is not save to do, cause in the later stages (application upgrades) i may want to add new icons to the app, so all id's may change? What is the best practice to store resource in case i do not want to store icons as blobs? As an example, let's say i have a game 1.0, where i let user to choose an avatar for his character from a list of avatars. I want to store this avatars id in DB and be sure that if i

How to get and set string Resource values in android

帅比萌擦擦* 提交于 2019-12-04 13:37:46
I've declare a String : <string name="Please">Please Select</string> in the res/values/Strings.xml . Now I want to access this String value but what I can get can go till id not value like: int i = findViewById(R.string.Please); But what I want is just the value of the string Please . Thanks for all of your answer but my problem is a little bigger What I wanted to do is just to display date with app_name from all your answers i can get the app_name String but whether I can set This app_name with current date <string name="app_name">My app</string> and also I'm to set my in this way My app(in

How to find out IDs or names of preloaded system drawables (bitmaps) from memory dump

倾然丶 夕夏残阳落幕 提交于 2019-12-04 13:12:09
问题 I'm analyzing memory usage of our app, and has found strange Drawables , which constantly "eats" few megabytes of heap. Here are few screenshots from MAT: Dominator tree with 2 pretty big bitmaps Path to GC roots for one of above bitmaps This bitmaps always appears in heap dumps from my phone ( Samsung Galaxy Nexus, OS 4.1.1 ), no matter how long or how intensive I use our app. I've already tried to search the source of this bitmaps using MAT - with no luck. All usefull information I was able

Storage limit in raw and asset folder in android

柔情痞子 提交于 2019-12-04 11:20:25
问题 I want to store some video/audio files in raw folder of my application. I don't know the storage limit of raw and asset folder. Can anybody tell me how much data i can store in raw and asset folder. And also what if i store bulk data in those folder, does it will affect to speed of execution or size of application to download from market? Thanks in advance. 回答1: There is no limits on any resources now after Android2.3 release the new aapt.The limitation is caused by the older aapt for system

Integer array of resource ids returns 0

六月ゝ 毕业季﹏ 提交于 2019-12-04 07:26:30
I have a set of resource ids stored in an array. This is accessed inside the recycler view to populate an image view. The problem is when I access the array, all values returned is 0. // arrays.xml <array name="array_category_icons"> <item>@drawable/autumn</item> <item>@drawable/backpack</item> </array> // inside recycler view adapter int[] myIcons = getActivity().getResources().getIntArray(R.array.array_category_icons); myIcons[i] always returns 0. The drawables are in the hdpi folder only. Do this: TypedArray ta = getResources().obtainTypedArray(R.array.array_category_icons); Drawable[]

Button variable turns to null after calling method

牧云@^-^@ 提交于 2019-12-04 06:58:05
问题 In my mainactivity I have the following snip MainActivity.class private Button btnx10; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Button btnx10=(Button)findViewById(R.id.MainCOPbtn); DrawLines(); } private void drawLines(){ float centerYOnImage1=btnx10.getHeight()/2; } I'm trying to access the button that is created in the onCreate() method from the method drawLines() i.e. in the same class MainActivity.class but outside of this method.

Conditional resource inclusion/exclusion for Android apk build

感情迁移 提交于 2019-12-04 04:37:39
I keep coming back to this problem, since there doesn't seem to be a clean solution. Does anyone have a good strategy to exclude resources from a child project in Android? I have two scenarios: 1 - Base library project has localization files for en, es, etc. --Child project 1 uses all localizations, and everything is good --Child project 2 is only localized to English, but the final .apk would have a partial localization due to the parent resources (although ADT19 or so added Lint rules to warn/prevent you from doing this). The only solution I have to this right now is to have a separate