android-resources

Android drawables : Is there any way to somehow link the int IDs to the R drawable IDs?

僤鯓⒐⒋嵵緔 提交于 2019-12-12 04:13:07
问题 I have 718 drawables in the drawable-mdpi , drawable-hdpi and drawable-xhdpi folders, whose names are 1.png, 2.png... to 718.png. (They are actually Pokémon sprites) So, depending on the Pokémon, I want to load one of them to show it. However, I cannot use the number to directly identify the R drawable ID. Is there any way (besides of a 718-case switch or a Hashmap<Integer,Integer> ) to somehow link the int IDs to the R drawable IDs? 回答1: You could try: String sprite = "drawable/"+number; int

Trying to get drawable resource ID from its name in Android

北城余情 提交于 2019-12-12 03:27:00
问题 I have a resource file like this: strings.xml <string name="category01">My Category 01</string> <string name="category02">My Category 02</string> <string name="category03">My Category 03</string> <string-array name="array_category_01"> <item name="title">@string/category01</item> <item name="image">@drawable/img01</item> </string-array> <string-array name="array_category_02"> <item name="title">@string/category02</item> <item name="image">@drawable/img02</item> </string-array> <string-array

Configuration properties file in Android project

佐手、 提交于 2019-12-12 03:19:55
问题 Where can I place configuration file in Android project? Currently I am made a directory in res directory as : res/config/configuration.properties and want to access it as : properties = new Properties(); properties.load(getClass().getResourceAsStream("config/configuration.properties")); It is not working : input stream is null 回答1: You can place it in assets directory as assets/configuration.properties Example code try { InputStream is = context.getAssets().open("configuration.properties");

Binary XML file line #53: Error inflating class ImageView

吃可爱长大的小学妹 提交于 2019-12-12 02:42:15
问题 I build my app against minSdkVersion 11 targetSdkVersion 23 When I run it on Samsug Galaxy S5 or Note5, the app runs fine with no problem. But when I try to run it on a Samsung S3 running android 4.4.2, it crashes with the following stack trace. I already read android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>. Does my stack trace shed some particular light so that someone can help me further? Also the reference to line 153 in MainActivity is simply

My Android application cannot find buttons declared in the XML file

北城余情 提交于 2019-12-12 02:20:05
问题 My application was working fine before reading in XML objects but now I have added to the two buttons and a textview to it it's having a problem finding them. So I added the three objects there for more control of my application and the activity class cannot find them public class TVListingTestActivity extends Activity implements OnClickListener { private static final String TAG = "myApp"; private EditText infoView; private String result; private String full; public int count; final Context

Get resource ID from URI or Bitmap

时间秒杀一切 提交于 2019-12-12 02:02:45
问题 Is there anyway I can find resource ID from Bitmap, URI, file path or file name of an image? These images are written by my app. So is there any chance I can find the resource ID? Basically, I have GIF images stored in my SD Card (which are created by my app). I want to load those images to my viewer. For that, I am using GIF Movie View library. In that file, setMovieResource() expecting an int (resource ID). But I have all other info like bitmap, absolute path. 回答1: Resource IDs are

Android Studio is it normal for R.id to access every components

自闭症网瘾萝莉.ら 提交于 2019-12-12 01:29:39
问题 I am working on a little Android Studio (version 2.2.3) application. After adding a second activity with a lot of components I noticed that when I type R.id in the first activity, the auto-completion proposes me the components from the second activity. Is this normal ? And here is a working example of my issue (I took the screenshot from it), for simplicity I just created two empty activities each one with a button. AndroidManifest.xml : <?xml version="1.0" encoding="utf-8"?> <manifest xmlns

Show string keys instead of values

只愿长相守 提交于 2019-12-11 19:01:21
问题 Is it possible to show the keys of my strings in strings.xml instead of the value, would be cool to check which key is it directly in the UI. for example <string name="jobs_key">Jobs</string> i would like to show in the UI jobs_key instead of Jobs 回答1: use Resources.getResourcesName(int) , Return the full name for a given resource identifier here you can find the documentation. You can also use reflection: private ArrayList<String> getKeysName(Context context, String className) { Class c;

App logo in actionbar appears larger on tablet vs phone

感情迁移 提交于 2019-12-11 18:14:36
问题 I'm having trouble figuring out why my app logo in the actionbar appears larger on a nexus 7 vs a nexus 5. I'm using the actionbar in the support library. They're both running android 4.2.2 Nexus 5 (good) Nexus 7 (bad) Here are the logo image resources. What can I do to fix? 回答1: The problem because of different dimension of the devices.You can fix it by alter your images for two different dpi.xhdpi for nexus 7 under the resolution of 1920 x 1200 pixels rate.xxhdpi for nexus 5 under the

Resource not found String resource ID

廉价感情. 提交于 2019-12-11 18:04:06
问题 I am making an which app which have 2 android project; 1st project is library project and 2nd project is my main project. project-1 is working fine but when I am adding it in my Project-2 as library it is giving me exceptions like this Resource not found String resource ID #0x76000456 when i checked my string bundle and R.java this string is there. I have tried clean Project restart my eclipse and my system. my strings.xml file looks like:- <string name="pref_loadrecent_id">loadrecent</string