I have tried right clicking on res and adding new folders and fils with -v11 at the end of the name but I don't see the folder in the res directory when I do this?
I have restared android studio and still don't see them? Or sometimes is says thats an invalid character?
I right click on res and this is what I see then I click new directory.
Thanks for the help in advance!!
The version qualifier starts with a "v". In your instance it would be menu-v11. If you don't see it go to Explorer/Finder/whatever and check for the folder presence there.
Also I'm guessing you're trying to provide different icons for the same menu for platforms below and above API 11. You do that by providing drawable-?dpi and drawable-?dpi-v11 resources. Then you have a different icon (with same name) for different platforms and only one menu resource which uses the icon.
EDIT: In Android Studio RC 1.0 everytime I create a layout resource it puts it in the /res folder instead of /res/layout. This is a bug and your problem may be related. I would check the parent folder.
Related
I want to add my app Icon to created folder instead of default folder icon.
I know i can create folder with following code.
String extr = Environment.getExternalStorageDirectory().toString();
File mFolder = new File(extr + "/My Application/Downloads");
if (!mFolder.exists()) {
mFolder.mkdirs();
}
By doing this, i'm getting following result.
but what i want is..
I have searched a lot, but no luck. can anyone help me out?
Thank you.
Directories do not have icons, and so whatever app or tool your screenshot is from is adding that. You would have to ask the developers of that app or tool what algorithm they are using to determine the icon to show.
Customization of folder icon is OS dependent.
On Windows you will use Desktop.ini file to assign a custom icon or thumbnail image to a folder. To simplify working with Desktop.ini you can use ini4j. Basically, you will need to create Desktop.ini in the folder, that you want to customize and specify path to the icon there. (Here is similar question)
On Mac OS the process is different. There are ways to access icons (for example, FileView or FileSystemView, also Quaqua). However I haven't found a way to set folder icon programmatically with Java.
Note: I assumed, that you want to add icon to arbitrary folder and not your app laucher.
After creating new directory you have to declare resource directory in your gradle file so that android studio can recognize new resource directory.
More information please refer https://developer.android.com/studio/write/add-resources
When you start a new android studio project, by default, you have a folder "values" and some other "values-XXXX" folders such as "values-v11" which its files are used when the API version of the device is above 11. I know that we can filter the values up to the language of the device too, by adding the directory "values-fa" . So the question is what are the other filters for values folder?
In Android Studio, when you are creating a new folder, you are given all of the qualifiers available on the left side of the window. In this example, I chose the Locale qualifier and on the right side I can choose the specific filter that I want:
In a JavaFX application i'm developing I use several icons to style some buttons and view objects. The first icons I used were displayed and packed to the deployed files (.dmg with .app and .exe) successfully, since I had to tell Ant to include the resources folder with the icons.
When I run the project with Eclipse, all the icons and images are displayed right, but when I deploy the project, only two of them (the last two included in the last improvement) are not shown. Why could be this, since I didn't change any folder or configuration?
When I get the deployed .app, I right click on it and clicking "show package contents" I can see that not only these two icons are not packed there in /Contents/Java/Resources/, but many others that mysteriously are actually shown in the application. For now I solved this copying all the required icons there, but I can't do this with the .exe generated file, which doesn't show these 2 correct icons.
My application is a music organizer/player called Musicott, is on github so you can see all the code there. The two icons are the slider thumb used to visualize and move through a track; and the default cover image for tracks that doesn't have one.
In this image you can see the problem better http://i.stack.imgur.com/8aVcz.png
Code where I set the default cover image at /com/musicott/view/RootLayoutController.java lines 503-506
Code where I set the default cover image in the play queue list at
/com/musicott/view/PlayQueueController.javalines 98-101
Code where I set the slider thumb icon in
/com/musicott/SceneManager.javalines 245-249
Thanks in advance. I will answer any doubt about the code and the project.
Nice looking project! So, as James_D pointed you are currently loading your icons with the following code:
new Image("file:resources/images/default-cover-icon.png")
new Image("file:resources/images/default-cover-icon.png", 45, 45, true, true));
The problem is that when you pack your application the "file" protocol is no longer valid (remember you are sending a URL to the Image constructor). You could send instead an InputStream (you can get one from the current Class), see this sample code:
new Image(RootLayoutController.class.getResourceAsStream("images/default-cover-icon.png"));
Now, if you use the code exactly like that you will need to make sure (after building the jar) that the "images" folder ends up inside the "com/musicott/view/" folder (since the RootLayoutController class is inside that package), so you will have to add the two extra "com" and "musicott" folders inside your current "resources" folders and move the "images" folder there.. you will probably need to add this in your pom.xml file too (to make sure you export the resources since I think maven will only export by default the "resources" folder located at "src/main/resources"):
<resource>
<directory>resources</directory>
</resource>
Note that if you want to keep your current folder structure (without creating the "com/musicott/view" folders inside the "resources" folder) you can change the path in the getResourceAsStream() call to "/images/default-cover-icon.png" (slash at the start of the string) to indicate that the images folder will be at the root.
Keep up the good work!
I currently deal with a tutorial for beginners to build my first Android application in Eclipse. I created a new Android project with default values. Next, Eclipse reports an error in the AndroidManifest.xml file. Here is the line producing the error:
android:icon="#drawable/ic_launcher"
This is the error message: error: Error: No resource found that matches the given name (at 'icon' with value '#drawable/ic_launcher').
How do I fix this?
Change ic_launcher to the name of the icon which is located in your project/res/drawable/ folder
This is a common error in Android. At some point, the Android new Project Wizard changed the default name it would give to the application icon (and some tutorials are still using the old name).
Please read more about Android fundamentals, so you can figure out how things are organized. A drawable is a resource. Resources are located in the res/ folder (although, resources are indexed in a R file which is automatically generated before everything gets compiled).
What it is saying is that there is no file drawable/ic_launcher. To fix this, simply create a drawable named ic_launcher.
You are missing "ic_launcher" in your draw able files, simply add one or remove the line of code.
This question already has answers here:
"R cannot be resolved to a variable"? [duplicate]
(30 answers)
Closed 2 years ago.
I got all of this code from here
I am extremely new to all of this, and am having a few problems.
The error "R cannot be resolved to a variable" comes up on the bold parts of this code.
Resources r = context.getResources();
**setBackgroundColor(r.getColor(R.color.candidate_background));
mColorNormal = r.getColor(R.color.candidate_normal);
mColorRecommended = r.getColor(R.color.candidate_recommended);
mColorOther = r.getColor(R.color.candidate_other);
mVerticalPadding = r.getDimensionPixelSize(R.dimen.candidate_vertical_padding);**
mPaint = new Paint();
mPaint.setColor(mColorNormal);
mPaint.setAntiAlias(true);
**mPaint.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_font_height));**
mPaint.setStrokeWidth(0);
The only thing I can think of is that I haven't copied and pasted everything correctly?
R is a Java class file that basically maintains an index of resources by assigning every resource that your application uses with an integer value for lookup. If you look in the res directory of the sample you're following, you'll see a values directory underneath it containing a colors.xml file that defines any custom colors. Note that in this specific example, you are using a color resource, not a Color State List resource as Paul had mentioned. Color state resources go in the color directory, but definitions of simple colors go in the values directory. Confusing, I know.
Resources in Android are defined via XML files. R.java is created automatically by the Android build process when these XML files are parsed. Different types of resources need to be placed in to specific directories for R to be structured properly; quite unhelpfully, not all of these directories are automatically created for you when you make a new project under an IDE.
Read this article about Application Resources, this article about providing resources, and this article about accessing resources (all Google documentation) for a bit of a better understanding.
Lastly, if you DO have all of your XML files in the proper place, check your import statements. Sometimes conflicts can arise if you have too many imports or if all of your imports aren't in place; if you're using the official Android Dev Tools in the form of the Eclipse plugin, the easiest way to handle imports is to use the Ctrl+Shift+O shortcut (Cmd+Shift+O on a Mac). If your imports are correct, and all of your XML files are in place, perform a rebuild on the project. If this still doesn't work and you are using Eclipse, I know that sometimes Resource resolution conflicts can inexplicably be fixed by simply closing Eclipse and launching it again.
R is an automatically generated file made from your resources.
Taken from Android docs
Color State List Resource
Define a color resources that changes
based on the View state. Saved
in res/color/ and accessed from the R.color class.
I would guess that the different R.color.candidate_* all need to be defined under res/color/
The R.java file should be automatically generated by Android. Try the following:
If you are using Eclipse try "project clean" to regenerate the file.
Use Ctrl-Shift-O to "reorganize" your imports. This will automatically add the R.java file to your imports if necessary.
Try to fix all errors not related to the R file and then retry the "project clean" and Ctrl-Shift-O option again. Other errors (e.g. typos in your xml layout files) can "stall" a new build of the R file via project clean.
Make sure your project is an Android project and you have an android.jar file on your classpath. If not fix this and retry step 1-3
you ned to copy the resources om the example you are using into the releavent directories in you res folder. The first word (after R.) is the directory you use.
so for R.color you put the resoruce in res/color in your project.
for the xample the resources are here:
http://developer.android.com/resources/samples/SoftKeyboard/res/index.html
they should also be in the version of the android SDK you downloaded:
ADKPATH/samples/android-/SoftKeyboard/
I got this error message many times. And mostly all of them were caused by some mistake in xml files or that I forgot to put 'check' in front of Build Automatically option. Try it! Maybe it will help You.