android-resources

Automatic string resources translate

折月煮酒 提交于 2019-11-30 09:54:26
When I run Android Lint check, I always get errors on my strings resource. The error says that I didn't translate my strings to all the languages. Assuming there are no people who know all the languages ​​in the world (if there are I'm not one of them), and that error has a realistic solution. How can I fix this problem? Is there any way to do it automatically (like with Google Translate)? The error is "<the-string-name>" is not translated in af, am, ar, be, bg, ca, cs, da, de, el, en-rGB, es, es-rUS, et, fa, fi, fr, hi, hr, hu, in, it, iw, ja, ko, lt, lv, ms, nb, nl, pl, pt, pt-rBR, pt-rPT,

WARN in logcat ResourceType: For resource …, entry index(…) is beyond type entryCount(1)

假装没事ソ 提交于 2019-11-30 09:01:29
I am getting these warnings on logcat every time the app renders some layout. Tried to search about but could not find a clue. I think is something related with resources (drawables, strings or values) but I don't know what is causing this. It's not an error, but is a little annoying. Somebody have an idea? 04-22 15:28:33.204 21943-21943/xx.xxx.xxxxxxx.xxxxx.xxxxx W/ResourceType﹕ For resource 0x01030128, entry index(296) is beyond type entryCount(1) 04-22 15:28:33.204 21943-21943/xx.xxx.xxxxxxx.xxxxx.xxxxx W/ResourceType﹕ For resource 0x01030224, entry index(548) is beyond type entryCount(1)

Android resource for a specific product

感情迁移 提交于 2019-11-30 08:53:28
i got this code from Settings app... <string name="about_settings" product="tablet">About tablet</string> <string name="about_settings" product="default">About phone</string> then my questions are: from where at runtime the system load the correct string resource ? What must I do to add a new product? e.g. <string name="about_settings" product="laptop">About laptop</string> nandeesh from where at runtime the system load the correct string resource ? The system does not load this at runtime. The correct string resource is preloaded according to PRODUCT_CHARACTERISTICS defined for a specific

How can I convert the android resources int to a string. eg.: android.R.string.cancel?

北慕城南 提交于 2019-11-30 08:03:18
How can I obtain the string value "cancel" from this resource int: android.R.string.cancel ? thank you Simply use Context#getString() : String string = getString(android.R.string.cancel); I've already tried this approach but with no success... I've a class: public class MyDialogFragment extends DialogFragment { A DialogFragment is not a subclass of Context, so you need to get access to a valid one (like your Activity's). Use this: String string = getActivity().getString(android.R.string.cancel); Or as your discovered you can use the Activity passed in onAttach() , but understand you can do

How does one use Resources.getFraction()?

怎甘沉沦 提交于 2019-11-30 08:00:36
How do I store a fractional value like 3.1416 in resources? What to write in the XML and how to retrieve it in Java code? The documentation for getFraction() states: public float getFraction (int id, int base, int pbase) Retrieve a fractional unit for a particular resource ID. Parameters base The base value of this fraction. In other words, a standard fraction is multiplied by this value. pbase The parent base value of this fraction. In other words, a parent fraction (nn%p) is multiplied by this value. Returns Attribute fractional value multiplied by the appropriate base value This answer

Android Styles: Difference between 'style=“@android:style/XYZ”' and 'style=“?android:attr/XYZ”'?

天大地大妈咪最大 提交于 2019-11-30 03:43:07
I'm trying to style buttons to look like those I ask about in Android Full Width ICS style Minimalist Bottom ButtonsViews . I've succeeded, with the following xml for anyone interested: <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="bottom" android:divider="@android:drawable/divider_horizontal_dark" android:gravity="bottom" android:orientation="vertical" android:paddingTop="16dip" android:showDividers="beginning|end" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android

How do I use obtainStyledAttributes(int []) with internal Themes of Android

佐手、 提交于 2019-11-29 23:08:36
So I have looked around and found out that android.R.styleable is no longer part of the SDK even though it is still documented here . That wouldn't really be an issue if it was clearly documented what the alternative is. For example the AOSP Calendar App is still using the android.R.styleable // Get the dim amount from the theme TypedArray a = obtainStyledAttributes(com.android.internal.R.styleable.Theme); lp.dimAmount = a.getFloat(android.R.styleable.Theme_backgroundDimAmount, 0.5f); a.recycle(); So how would one get the backgroundDimAmount without getting the int[] from android.R.styleable

Can localization resources be downloaded in runtime?

大城市里の小女人 提交于 2019-11-29 19:30:31
问题 I have application with internet access and don't want to store many string.xml files for different languages. What I want: Application contains only one string.xml with english strings. When user launches it - I see user's phone locale, and ask my own server for necessary language file. (resource keys will be the same) When new resource file comes, all interface should work with new file. The question is how to change existing or add new string.xml file in runtime? 回答1: You obviously cannot

Button variable turns to null after calling method

情到浓时终转凉″ 提交于 2019-11-29 18:49:21
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. When I am trying to access the button in the drawlines() method it's value is null. How can I access

How to find resource id of a file located in /res/raw folder by its filename?

此生再无相见时 提交于 2019-11-29 18:14:06
I want to get the resource id of the file located in /res/raw folder by filename. I have tried the following 2 methods but both of them return resource id as 0 (zero). Method 1: String filename = "abc.txt"; int id = getResources().getIdentifier(filename, "raw", getPackageName()); Method 2: String filename = "abc.txt"; String fullyQualifiedName = getPackageName() + ":raw/" + filename; int id = getResources().getIdentifier(fullyQualifiedName, null, null); If this is not the correct way, then how do we get the resource id by filename located in raw folder in Android. Drop the extension: String