android-resources

Get Uri from file in either assets or res/raw

会有一股神秘感。 提交于 2019-12-06 09:35:25
I have tried to get this working and I have looked at many different resources online (as you can see from all of the comments I have made). I want to access a .pdf file that is either located in assets or res; It does not matter to which one so the easiest way will do. I have the method below that will get the actual file and will call another method(under the first method below) with the Uri in the parameters. Thank you very much for your help and I will be standing by to answer questions or add more content. private void showDocument(File file) { //////////// ORIGINAL //////////////////// /

Clarification on 'private' drawables in android.R.drawable

倖福魔咒の 提交于 2019-12-06 03:29:05
问题 I am making a menu for an app and was pointed to this useful resource which lists all the drawables that are part of the android 2.0 jar. the usage example given is myMenuItem.setIcon(android.R.drawable.ic_menu_save); Unfortunately, the one I want (and most of the list) are not available by default. I get android.R.drawable.ic_menu_login cannot be resolved when I try to set the menu item images: @Override public boolean onCreateOptionsMenu(Menu menu) { // Add two example menu buttons int

Integer array of resource ids returns 0

柔情痞子 提交于 2019-12-06 03:27:43
问题 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.

Change strings in notification bar after a change in the locale

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 22:37:24
I have few string.xml files for different languages, and when I change my locale everything is okey all my labels in my activity are changed except the one in the notification. Is there anything like a 'refresh' command to send to the notification? to refresh the strings? Bo. This issue has been reported number of times on different forums. Probably the most appropriate solutions/workaround can be found here: android - locale notification, need to dump cache Kind regards, Bo 来源: https://stackoverflow.com/questions/10832903/change-strings-in-notification-bar-after-a-change-in-the-locale

Dynamically Set ID to a Button in Android

点点圈 提交于 2019-12-05 21:58:20
I want to dynamically create a button but am having an issue when it comes to setting an ID for it. I tried putting an integer value in there but keep getting an error that says "Expected Resource of Type ID." The issue is that I DONT want to create this Button in my XML file and yet I need a way to track it with an ID. Please Help. Button changeButton = new Button(getApplicationContext()); changeButton.setText("Change"); changeButton.setId(1);//Keep Getting an error here In your res/values folder you can keep an ids.xml file, where you can define: <resources> <item type="id" name="your_button

Android Build in Eclipse not generating the right resource ids in R.java

旧城冷巷雨未停 提交于 2019-12-05 17:28:16
I've got an Android project that includes references to a library project. The library project contains a resource (a renderscript bytecode package). The main project also has it's own resources, including a layout, which contains a field that looks like this: <EditText android:id="@+id/edit_name" /> When I build my main project in ant, and I call findViewById(R.id.edit_name) at runtime, the call returns the EditText component I expect. But when I clean the projects and build them in Eclipse findViewById(R.id.edit_name) returns null . Debugging the call shows that my component is present in

Is it possible to use sub folders in drawables in Android? [duplicate]

扶醉桌前 提交于 2019-12-05 16:34:09
问题 This question already has answers here : Can the Android drawable directory contain subdirectories? (20 answers) Closed 5 years ago . In my application I have several folders and subfolders of images. They are inside drawables. How can I retrieve images from drawables subfolders? Example: drawable>actions>sports>soccer.png How can I get this "soccer.png" photo? Any help is appreciated. Thanks! 回答1: No , the android resources mechanism doesn't support subfolders in the drawable directory, you

BitmapFactory.decodeResource and drawable* folders

送分小仙女□ 提交于 2019-12-05 15:47:23
问题 I am wondering if decodeResource (Resources res, int id, BitmapFactory.Options opts) takes into account the drawable-ldpi,mdpi,hdpi etc. folders. I checked the source code, and it doesn't look like that, but I may be missing something. (Generally, where are the R.drawable. resolved in Android source? I was unable to find it.) 回答1: Yes it takes it into account. For example if you do : Resources res = getContext().getResources(); int id = R.drawable.image; Bitmap b = BitmapFactory

How to get programmatically list of supported languages in an Android project (NOT device)

ぃ、小莉子 提交于 2019-12-05 15:11:35
问题 In some project we can have this situation How to get programmatically list of supported languages by this app/project? As the result I need string array like this { "en", "bg", "bs", "da", "de", "hr", "it", "nl", "pl", "pt", "sk", "sr", "tr" } Of course I can hardcode it by typing it but I suppose code can and should do it. And why I need it - I have a separate library that deals with localization, instant change of UI after selecting new language etc. App must tell library which languages

Android 7.0 Nougat picks up default strings when device language is en_US

吃可爱长大的小学妹 提交于 2019-12-05 12:32:36
As per the documentation in Language and Locale there have been improvements to Resource-Resolution Strategy from Android 7.0(API level 24) which is easy to understand with the following table: Improved Resource-Resolution strategy As per my requirements, I want my app's default langauge to be en_US. So, I am not providing separate resources for en_US. I also have en_GB resources present separately. Now, as per the resolution strategy, if my device's language is en_US then the order in which it should look for resources is en_US -> en -> en_GB -> default which means for all locales of en, in