android-resources

Downloadable Fonts Exception

送分小仙女□ 提交于 2019-12-23 20:23:15
问题 I decided to use Downloadable fonts in my project. I implemented everything as recommened in the guide. The following problem occured, when i tried to get font from ResourcesCompat next way: ResourcesCompat.getFont(MainActivity.this, R.font.roboto_bold) After that, i always get this exeption: Font resource ID #0x7f090005 could not be retrieved How to solve this problem? PS: support-compat library v27 min sdk 16 solution via ResourcesCompat.FontCallback is not a good way in my case problem

Cannot resolve R.java, duplicate class

守給你的承諾、 提交于 2019-12-23 19:04:14
问题 I just start using Android Studio for a week and it works great for me, but when I started Android Studio today I get the error: 'error: duplicate class: mypackage.R'. I saw this error before when I used Eclipse so I tried to rebuild the project a few times and restarting Android Studio, this didn't help. After reading some Stackoverflow questions I tried to deleted R.java and rebuild again, now I don't get any error while rebuilding. The only problem is that Android Studio cannot resolve R,

Possible to get color with string?

一曲冷凌霜 提交于 2019-12-23 16:55:12
问题 In my values folder I have my_colors.xml : <resources> <!-- Orange --> <color name="orangePrimary">#f6a02d</color> <color name="orange1">#e3952a</color> <color name="orange2">#da8f28</color> <color name="orange3">#d08926</color> </resources> Is there a way to get these colors just with the string of its name? Something like view.setBackgroundColor.getColor("orange1"); For images you have this getResources().getIdentifier("my_image", "drawable", getPackageName()); Hope you guys know what I

Android player raising exception prepare failed:status 0x1

南笙酒味 提交于 2019-12-23 15:37:49
问题 I am trying to play audio file from res/raw folder. but getting the error prepare failed: status = 0x1 My code: package com.example.lvm; import java.io.IOException; import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class MainActivity extends

Drawables pulled from wrong resource folder on rotation

浪尽此生 提交于 2019-12-23 15:15:35
问题 Pulling my hair out here. So I'm working with an application that has several types of drawables, and I have them in a structure like so: res/ //Portrait resources drawable-mdpi/ drawable-hdpi/ drawable-xhdpi/ //Landscape resources drawable-land-mdpi/ drawable-land-hdpi/ drawable-land-xhdpi/ EDIT I've also tried even putting the portrait-specific drawables under drawable-port-mdpi , etc. with the same result. And I have a custom View which I'm using to pull in drawables at runtime. Here's a

Can I mark a resource in my android project as deprecated?

牧云@^-^@ 提交于 2019-12-23 07:29:09
问题 I have an android library for which I would like to mark some resources as deprecated. Drawables, dimensions, durations... I read somewhere that I could add deprecated="deprecated" to the resource definition but it doesn't seem to do anything. In Android R you can see things such as @java.lang.Deprecated public static final int autoText = 16843114; I'm trying to produce something similar by editing durations.xml, values.xml, or even public.xml... Thanks! 回答1: Short answer: Not possible.

can I open a read alone database from res/asset folder in android without copying to database folder

岁酱吖の 提交于 2019-12-23 05:11:57
问题 I want to open a database and read some values from asset or resource folder.I don't want to write any data to DB.since my db size is huge I cant copy it to database folder as it will consume lot of time and memory. Any help? 回答1: Sorry, but this is not possible. SQLite cannot work with purely an InputStream , which is all you can get from an asset or raw resource. Remember that assets and resources are not files on the device — they are only files on your development machine. 来源: https:/

Iterate through certain images in res/drawable-mdpi

走远了吗. 提交于 2019-12-23 04:35:34
问题 In the res/drawable-mdpi folder I have 26 letter images, named big_0.png to big_25.png . I would like to add them all (and ignore any other images in the folder) to a hash map: private static HashMap<Character, Drawable> sHash = new HashMap<Character, Drawable>(); Initially I was planning something like: private static final CharacterIterator ABC = new StringCharacterIterator("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); int i = 0; for (char c = ABC.first(); c != CharacterIterator.DONE; c = ABC.next(), i++)

Language resources in separate APK?

南楼画角 提交于 2019-12-23 02:38:31
问题 I'm wondering if it is possible to create a separate APK file which contains only language specific strings and somehow persuade my program to try to read the string resources first from that package's resource and then from the program's own resources... I would like to have a main program with 2-3 mayor laguages and the rest of the languages would go into a separate language pack. (This is to keep the main program size small as I have already 12 translations) 回答1: You can access another APK

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

℡╲_俬逩灬. 提交于 2019-12-22 08:18:56
问题 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