android-resources

Dynamically Set ID to a Button in Android

我只是一个虾纸丫 提交于 2019-12-07 17:40:37
问题 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 回答1: In your res

Change strings in notification bar after a change in the locale

橙三吉。 提交于 2019-12-07 17:02:21
问题 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? 回答1: 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:/

Styling Sherlock Action Bar

老子叫甜甜 提交于 2019-12-07 10:29:27
问题 I'm trying to set an image as background of the Sherlock Action Bar, but even if the it's 720 x 112 px, it seems like the image doesn't stretch. The white part is still part of the Action Bar, as the triangle is set in the correct position and the button on the right, has different margins on the top and at the bottom. Do I need to make it a 9patch image? Not sure why it doesn't work.. I'm setting the background with a getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R

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

本小妞迷上赌 提交于 2019-12-07 08:46:06
问题 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

How to include 2 variants of Serbian Language? with Latin letters and with Cyrillic letters

旧城冷巷雨未停 提交于 2019-12-07 06:54:51
问题 I have an android app and I want to translate to Serbian and I want both variants of the language: with Latin letters and with Cyrillic letters. I tried this variants: value-sr-rRS-Latn , value-sr-Latn , value-sr-rRS-Cyrl , value-sr-Cyrl but not of that is working. I get this error: android-apt-compiler: [NAMEOFAPP] invalid resource directory name: [path]\res/value-sr-rRS-Latn On Android documentation about res dirs and Locale I can't find this option. Can I make 2 dirs with 2 variants of the

Library to encryption and decryption resources

戏子无情 提交于 2019-12-07 04:44:19
问题 My question is related to following questions. Security of Android assets folder Assets Security in Android Basically the application which I am making has some mp3 resources which I wanted to secure. So is there library which work on android to encrypt and then decrypt resources especially mp3 files. Thanks. 回答1: Keep in mind that any method of encryption that you use will need storing the key to decrypt the encrypted data. This key will have to be available to your application and thus to

ImageButton background swiching on it's own? Drawables gone wild?

与世无争的帅哥 提交于 2019-12-07 04:06:29
I having an issue where the ImageButton background is being drawn with a different drawable from one of my resources. I'm setting the background to be transparent but on some cases it's picking up one of my drawables called bottom_shadow.9.png. Why why!? It's freaking weird... I've seen this issue before... Some of my app users have complained seeing this issue and now I'm determined to figure this out! Take a look below what I currently have. Any tips or ideas would help. The color value I created under values/colors.xml: <color name="transparent">#00000000</color> My ImageButton under my one

Android Menu icons don't appear in the release build but display in the debug build

。_饼干妹妹 提交于 2019-12-06 12:29:37
I am facing one of the most bizarre issues in rcent times. I am using AppCompatActivity with android support v7. When I am running the app in debug mode I can see the menus with icons, after generating signed apk and installing, the icons vanishes from menu. 1) Release Build screenshot 2) Debug build screenshot Here is my menu code <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".TerminalActivity"> <item android:id="@+id/action_streamConnect" app:showAsAction=

Get all string resources from XML resource file?

*爱你&永不变心* 提交于 2019-12-06 12:07:48
问题 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. 回答1: 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

Retrieve a color from values/colors.xml using a variable in name (R.color.name + variable)

余生长醉 提交于 2019-12-06 11:47:10
I have a list of colors in my colors.xml that all have names in the format tColor1, tColor2, tColor3, etc. and I want to retrieve them in a for-to-do loop using the looping integer as part of the name. So I have for (int i = 0; i < numTrails; i++) { newColors[i] = R.color.tColor + i; } Now I understand that I can't use the R class like that, but what other method can I use to get the colors? You can do something like this, assuming your newColors Array is an int Array with the resource ids? String colorId = "tColor"; Resources resources = getResources(); for (int i = 0; i < numTrails; i++) {