android-resources

Android how to get access to raw resources that i put in res folder?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 13:05:07
In J2ME, I've do this like that: getClass().getResourceAsStream("/raw_resources.dat"); But in android, I always get null on this, why? Adrian Vintu InputStream raw = context.getAssets().open("filename.ext"); Reader is = new BufferedReader(new InputStreamReader(raw, "UTF8")); For raw files, you should consider creating a raw folder inside res directory and then call getResources().openRawResource(resourceName) from your activity. sravan In some situations we have to get image from drawable or raw folder using image name instead if generated id // Image View Object mIv = (ImageView) findViewById

Android Studio 3.1 Cannot Resolve Symbol (Themes, Widget, attr, etc.)

南楼画角 提交于 2019-11-26 12:23:35
问题 I upgraded Android Studio today to 3.1, and now Android Studio says it cannot resolve symbols for most of the resources (for example ThemeOverlay in styles.xml or ?attr/actionBarSize ). This doesn\'t seem to prevent me from building or running in an emulator so far, but these errors are making me nervous. Has anyone else experienced this issue? How can I go about resolving it? I have tried syncing gradle and cleaning my project but it doesn\'t seem to help at all. Any ideas? I\'m using

Gradle finished with non-zero exit value 1 (ic_launcher.png: error: Duplicate file)

非 Y 不嫁゛ 提交于 2019-11-26 12:21:14
问题 I got this strange error with gradle, please help me! /.../app/build/intermediates/res/debug/drawable-xxhdpi-v4/ic_launcher.png: error: Duplicate file /.../app/build/intermediates/res/debug/drawable-xxhdpi/ic_launcher.png: Original is here. The version qualifier may be implied. Error:Execution failed for task \':app:processDebugResources\'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process \'command \'/.../sdk/build-tools/22.0.1/aapt\'\'

Android Resources$NotFoundException: Resource ID #0x7f030027

∥☆過路亽.° 提交于 2019-11-26 12:16:12
问题 I was working on my android program and when I tried testing it I suddenly started getting an error that went \"android.content.res.Resources$NotFoundException: Resource ID #0x7f030027\" The last major change I made was adding in the action bar via the support library but I got that working fine already. Besides that I\'ve added one new class but even if I delete the class and it\'s associated files the error still pops up. I have tried cleaning the project and restarting Eclipse multiple

Avoid Android Lint complains about not-translated string

三世轮回 提交于 2019-11-26 12:09:36
问题 is it possible to specify that the strings in a file within the value-* directories are purposely not translated into other languages? I have a bunch of strings that are common for all the languages and need no translation, so I\'ve created an unlocalized-strings.xml file within values directory.. Running Android Lint to check for problems it keeps saying that some translations are missing.. I do not want to disable this check on the whole project, I\'d like to disable it only in some XML

Android: html in strings.xml

老子叫甜甜 提交于 2019-11-26 12:04:53
问题 I would like display for example this html code: <body> <p><b>Hello World</b></p> <p>This is a test of the URL <a href=\"http://www.example.com\"> Example</a></p> <p><b>This text is bold</b></p> <p><em>This text is emphasized</em></p> <p><code>This is computer output</code></p> <p>This is<sub> subscript</sub> and <sup>superscript</sup></p> </body> I want to display it on a Dialog by declaring html in resources strings.xml . How can I do it? 回答1: The best way to add html source code in strings

How to fix: android.app.RemoteServiceException: Bad notification posted from package *: Couldn&#39;t create icon: StatusBarIcon

南楼画角 提交于 2019-11-26 11:12:48
I'm seeing the following exception in crash logs: android.app.RemoteServiceException: Bad notification posted from package com.my.package: Couldn't create icon: StatusBarIcon(pkg=com.my.package user=0 id=0x7f02015d level=0 visible=true num=0 ) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1456) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5487) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android

Android Studio cannot resolve R in imported project?

我是研究僧i 提交于 2019-11-26 10:41:30
问题 I\'m trying the new Android Studio. I\'ve exported a project from eclipse, using the build gradle option. I\'ve then imported it in Android Studio. The R.java file under gen has a j in a little red circle on it. And in my source files, I get \"cannot resolve symbol R\" wherever I have a reference to a resource, e.g. \"R.layout.account_list\" etc. I have never used Intellij before. Would appreciate any help as there obviously aren\'t many answer yet about Android Studio. Thanks! 回答1: Press F4

Fast ways to import drawables in Android Studio?

孤者浪人 提交于 2019-11-26 09:31:46
问题 At some point in an Android project you will need to import some drawables - be it toolbar icons, images, UI features - in res/drawable directory. Most of the times you have images scaled for the most common qualifiers ( drawable-hdpi , drawable-mdpi , drawable-xdpi , drawable-xxdpi , ...). So we need to do three, four, even five file copy/pastes for each drawable: external_dir/drawable-mdpi/file.png -> my_package/drawable-mdpi/file.png external_dir/drawable-hdpi/file.png -> my_package

String Resource new line /n not possible?

微笑、不失礼 提交于 2019-11-26 09:19:45
问题 It doesn\'t seem like it\'s possible to add a new line /n to an XML resource string. Is there another way of doing this? 回答1: use a blackslash not a forwardslash. "\n" <?xml version="1.0" encoding="utf-8"?> <resources> <string name="title">Hello\nWorld!</string> </resources> Also, if you plan on using the string as HTML, you can use <br /> for a line break( <br /> ) <?xml version="1.0" encoding="utf-8"?> <resources> <string name="title">Hello<br />World!</string> </resources> 回答2: I know this