android-resources

Creating ArrayAdapter using xml resource and retrieving “id” or “value” fields using spinner

可紊 提交于 2019-12-22 07:03:43
问题 I am trying to create a spinner, the values of which I am populating from a resource xml, using ArrayAdapter. I also want to give the resource items some "id" or "value". How can i retrieve these values inside the onItemSelected() callback ? Here is the Java code. package com.waus.waus; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import

How to get and set string Resource values in android

空扰寡人 提交于 2019-12-21 20:04:46
问题 I've declare a String : <string name="Please">Please Select</string> in the res/values/Strings.xml . Now I want to access this String value but what I can get can go till id not value like: int i = findViewById(R.string.Please); But what I want is just the value of the string Please . Thanks for all of your answer but my problem is a little bigger What I wanted to do is just to display date with app_name from all your answers i can get the app_name String but whether I can set This app_name

Couldn't resolve resource @style/Widget.Holo.Light.ActionMode.Inverse

可紊 提交于 2019-12-21 08:24:09
问题 I'm creating an Android app in Android Studio. When I open the layout editor, I see that gray "popup window" on top of the layout, which says that it Couldn't resolve resource @style/Widget.Holo.Light.ActionMode.Inverse. This happens when I change the "rendering version" to API 15 ( Android 4.0.3 ). It worked a minute ago, but when I switched back to the layout, I just got this error. Edit: I use the AppCompat library. The theme is defined like this <style name="AppTheme" parent="Base.Theme

Couldn't resolve resource @style/Widget.Holo.Light.ActionMode.Inverse

时光毁灭记忆、已成空白 提交于 2019-12-21 08:22:04
问题 I'm creating an Android app in Android Studio. When I open the layout editor, I see that gray "popup window" on top of the layout, which says that it Couldn't resolve resource @style/Widget.Holo.Light.ActionMode.Inverse. This happens when I change the "rendering version" to API 15 ( Android 4.0.3 ). It worked a minute ago, but when I switched back to the layout, I just got this error. Edit: I use the AppCompat library. The theme is defined like this <style name="AppTheme" parent="Base.Theme

Missing XML resource type for PercentRelativeLayout Percentage value?

放肆的年华 提交于 2019-12-21 07:05:30
问题 It seems that the new Percent Support Library was released without allowing to reference a Percentage value in a dimension xml file. That is, instead of : <android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"/> <ImageView app:layout_widthPercent="50%" app:layout_heightPercent="50%" app:layout_marginTopPercent="25%" app

TypedValue Converting to String

隐身守侯 提交于 2019-12-21 03:30:31
问题 At random points while I'm using my Android application, LogCat is flooded with dozens of repetitions of the following 5 lines: 10-26 12:53:30.372 21270-21270 W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f0b00d8} 10-26 12:53:30.372 21270-21270 W/Resources﹕ Converting to string: TypedValue{t=0x1d/d=0xffe51c23 a=2 r=0x7f090047} 10-26 12:53:30.374 21270-21270 W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f0b008a} 10-26 12:53:30.375 21270-21270 W

How to use Android quantity strings (plurals)?

狂风中的少年 提交于 2019-12-21 03:15:07
问题 I am trying to use getQuantityString method in Resources to retrieve Quantity Strings (Plurals) based on android developer guidelines Quantity String (Plurals) The error I am getting is Error:(604) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? Error:(604) Found tag </item> where </plurals> is expected when I set up plurals as below <plurals name="productCount"> <item quantity="one" formatted="true">%1$d of %2$d product</item>

Tool to batch convert android resource bitmaps to different densities

我的未来我决定 提交于 2019-12-20 23:24:03
问题 I need to post-release support different display densities on Android During development drawable-hdpi has grown to 160 png (like 20 of them 9 patch) assets I now need to convert all those bitmaps to mdpi, ldpi (layouts and drawables XML are already fine, to avoid raising OOM on LayoutInflater Is there any tool suitable to convert all those bitmaps in batch ? 回答1: Here is a simple script to create lower-resolution Android drawables from higher-resolution ones. For example, given a batch of

Android ImageView setImageResource in code

房东的猫 提交于 2019-12-20 08:49:16
问题 I have an imageView that i want to display a little icon of the country that you are currently in. I can get the country code, but problem is i can't dynamically change the imageView resource. My image files are all lowercase (Example: country code=US, image file=us) My code (countryCode is the current countryCode in uppercase letters): String lowerCountryCode = countryCode.toLowerCase(); String resource = "R.drawable." + lowerCountryCode; img.setImageResource(resource); Now, of course this

Where to store sensitive global information such as API keys in Android application?

跟風遠走 提交于 2019-12-19 05:58:11
问题 I need to store some sensitive information in an Android application. If I put it in a resource file, it appears that it is trivial for another app to be able to browse and read that file simply by using PackageManager.getResourcesForApplication(). Where is the correct place to put information like this that we don't want people to be able to easily snoop? Should it be in a compiled java file? Or are classfiles also easily readable? Also, if they're in java files, is it possible to reference