android-resources

NullPointerException at android.content.ContextWrapper

巧了我就是萌 提交于 2019-12-01 18:04:00
问题 When I try to get a color via getResources().getColor(R.color.yellow) in a normal Activity I get this exception: 07-12 11:58:38.019: E/AndroidRuntime(3233): FATAL EXCEPTION: main 07-12 11:58:38.019: E/AndroidRuntime(3233): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.moveinblue.planner/com.moveinblue.planner.controller.plan.PlanDayScreen}: java.lang.NullPointerException 07-12 11:58:38.019: E/AndroidRuntime(3233): at android.app.ActivityThread

How to reference an XML file in Android Javadoc? [duplicate]

北战南征 提交于 2019-12-01 18:01:00
This question already has an answer here: Reference resources in javadoc 3 answers Is there a way to use JavaDoc links to reference Android XML files in res folder. Something like {@link res/values/custom_strings.xml} . {@link com.yourApp.R.layout#layoutName} Bryan Baan Someone else answered this question in another topic. Here's the link: https://stackoverflow.com/a/24814578/7262915 Hope this helps you! 来源: https://stackoverflow.com/questions/41433645/how-to-reference-an-xml-file-in-android-javadoc

Android resources “best match” fallback logic

折月煮酒 提交于 2019-12-01 11:08:40
I've read the docs about Android Resources and I think I've understood the best-matching logic used by android to identify in which directory a particular resource should be searched first.. Supposing that drawable-hdpi , drawable-en-port and drawable-en* match the current device configuration, drawable-en-port is the best matching directory.. My question is, if a drawable is not found in drawable-en-port , does the system look directly in drawable or does it look in the second-best-match drawable-en and then in the third best match drawable-hdpi and so on until it reaches drawable ? I suppose

Android resources “best match” fallback logic

走远了吗. 提交于 2019-12-01 09:41:45
问题 I've read the docs about Android Resources and I think I've understood the best-matching logic used by android to identify in which directory a particular resource should be searched first.. Supposing that drawable-hdpi , drawable-en-port and drawable-en* match the current device configuration, drawable-en-port is the best matching directory.. My question is, if a drawable is not found in drawable-en-port , does the system look directly in drawable or does it look in the second-best-match

Warnings in xml resources

夙愿已清 提交于 2019-12-01 09:29:15
Yesterday I installed ADT plug-in again as I was having problems (intermittent) with the version I already had. The thing is, I'm not getting warnings in all my xml resources. I am pretty darned sure I haven't seem them before. Some of these are annoying because I cannot do anything about it: Nested weights are bad for performance The resource R.attr.TextAppearance_Group_Small appears to be unused Replace "..." with ellipsis character (…, …)? Others that I've had to fix include: This tag and its children can be replaced by one <TextView/> and a compound drawable [Accessibility] Missing

Warnings in xml resources

ぐ巨炮叔叔 提交于 2019-12-01 07:07:48
问题 Yesterday I installed ADT plug-in again as I was having problems (intermittent) with the version I already had. The thing is, I'm not getting warnings in all my xml resources. I am pretty darned sure I haven't seem them before. Some of these are annoying because I cannot do anything about it: Nested weights are bad for performance The resource R.attr.TextAppearance_Group_Small appears to be unused Replace "..." with ellipsis character (…, …)? Others that I've had to fix include: This tag and

Adding a bitmap to the drawable resources

自作多情 提交于 2019-12-01 05:43:18
How can I add a Bitmap taken from the web (in the app i mean!) to the drawable resources? So i can access the Bitmap using R.drawable.bitmapName ... Cristian You can't modify that folder once your app is installed. In that case, you must copy the bitmap to a file and access it from there. Take a look at this other question: Save bitmap to location The resources are compiled at the apk building time, so you cannot change it in runtime. If you want to have some identifier you can consider creating a shared preference where you can put in relation the downloaded image file with some id. But it

Android access to resources outside of activity

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 05:06:10
问题 I would like to know - are there ways to access android resources and/or assets files (or files from any other folder) outside of an Activity ( without passing context )? Can't access without context: getResources().getIdentifier("resource_name", "drawable", getPackageName()); getAssets().open("file_in_assets_folder_name"); Throws Exception if not in Activity: try { Class class = R.drawable.class; Field field = class.getField("resource_name"); Integer i = new Integer(field.getInt(null)); }

Why Android cannot deal with Resources name conflict between Project and Library?

穿精又带淫゛_ 提交于 2019-12-01 04:40:26
问题 I have a project A that referenced by Library B, A and B have the same name and type, but their value are different. I think aapt should deal with this issue that make sure project and library access the correct value. besides renaming all the resource in project or library, what else should I do to solve this problem? 回答1: The build system intentionally makes all project resources overlay on top of the library resources. This is done on purpose to be able to customize a library resource

Is it possible to do string substitution in Android resource XML files directly?

佐手、 提交于 2019-12-01 04:00:44
In my android app, I have a large string resource xml file. I want to make reference and reuse declared resources values within String values. Is it possible to have the R class resolve referenced values (a la @string/db_table_name)? <resources> <string name="db_table_name">tbl_name</string> <string name="ddl">create table @string/tbl_name</string> </resources> Is there a way of doing this. In regular Java world, some tools use ${varname} expression to resolve reference. Can this be done at all in Android? Add a %s to your second resource string (the one that you want to be dynamic) where you