Android images affecting each other - java

In my drawable folders i have my icon image, and when testing i use it as a temp picture. I added 2 other images and a XML file and when ever the app loads the imageviews with the icon set to it has different images..
this is what it is meant to be be..
but this is what it is when i add other images to the drawable folder
And no, the names of the files are not the same.
The icon is called 'icon.png' - thats what it should be
instead it is 'ic_menu_compose.png' - a completely different name.
Also the files i'm adding are called:
'buttonnormal.png'
'buttonclicked.png'
and a XML file - 'buttonselector.xml'
Even if i dont use these images any where within my app the problem still occurs.
Any help would be much appreciated. Thanks! :)
[EDIT]

Are you building your app inbetween tests?
In eclipse: Project > Build Automatically (ticked) (this regenerates your R file)
Are you referencing the image by a raw ID?
setImageResource(324234234); WRONG
setImageResource(R.drawable.blah); Right
Are you using drawable image names that are already in use by the Android system: http://androiddrawableexplorer.appspot.com/
Personally I would rename that images from "ic_menu_compose" to something like "icon_menu_compose_overwritten" just incase it is clashing and screwing up your R file.

Related

create folder with app icon instead of default folder icon

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

change the default image for the start libgdx app

I'm trying to figure out how to change the following image on start app with LibGdx framework.
I would like to customize it with my logo , but I can not find the reference in the solution .
Thanks for your help.
For IOS platform you should add in your ios/assets folder your own splash images in all resolutions with defined naming structure of Apple.
"Default.png" - 320x480 iphone3gs
"Default#2x.png" - 640x960 iphone4
"Default~ipad.png" - 768x1024 ipad
"Default#2x~ipad - 1536x2048 ipad retina
...etc
more details you can find here ..
Libgdx project for iOS displaying libgdx splash when compiling through robovm on simulator?
In windows explorer go to <path to your project>/desktop/assets
You'll see the default LibGDX image and here you can put all of your assets files (images, fonts, etc). You may also need to refresh your project folders in Android Studio so that the new image(s) will show up.
The java file that loads the image is under the core/src folder. Open this file and you will see where it loads the default image. Change the name of the image to the name of your new image and that should do it.
NOTE: If you are planning to build for android also, android will only see assets that are located in the android/assets folder (it's annoying, but this is the only way it works). I don't use Android Studio, but look up how to set the working directory for your desktop project to use the android/assets folder (instead of desktop/assets). Then put all of your images into the android/assets folder. This one took me a while to find out when I first started building for android. So if your desktop build works, but android doesn't...this is what you need to do to fix it. :)
1)for android, go to asset folder and paste your image
2)Refresh the asset folder
3) in your create method
//libgdx.png is the default image name that provided by the libgdx
texture = new Texture(Gdx.files.internal("data/libgdx.png"));
//in above code remove that "libgdx.png " and add your image name
Example:-
texture = new Texture(Gdx.files.internal("your image name.png"));

Hidden resource files deploying a JavaFX application

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!

Eclipse emulator isn't running up to date version of android app

I'm using eclipse, and my app is at a point where there is a background, and when I run the emulator it doesn't have the background. It had done this before where I changed some text, but when I ran the emulator the text stayed the same. If someone could tell me what I am doing wrong then that would be great. Thanks.
I have noticed that changes made to xml files sometimes do not show up unless you do Project > Clean...
i tried the layout it works fine. You create a folder named as drawable similar to drawable-hdpi. Put your image inside the drawable folder. It work fine.
or
Blockquote
Another option about the problem is that you created you Emulator in such a way that the Android OS determines its screen as xhdpi. If an image is placed in drawable resource folder then Android will try to rescale it for the different resolutions. However if the image appears only in some of the resolution folders (lie drawable-ldpi etc) then the image will be served only in this resolutions.
Please, either create folder drawable-xhdpi and place the image also there, or create folder drawable and place the image there. It will be used for backup.
See the documentation about the image folders: http://developer.android.com/guide/practices/screens_support.html

Where to put smartgwt icons folder in project tree?

setNodeIcon("icons/person.png");
or
setIcon("icons/person.png");
In respectively SmartGWT TreeGrid and Tab (in TabSet) should find "person.png" in folder "icons" I guess but where should I put "icons" in the project itself?
In the JavaDoc it's also said that the default value for setNodeIcon is [SKIN]file.gif what does [SKIN] mean ?
Thanks
I don't know where you find the default value (to my sense this use of the Skin folder is for using images already in the smartgwt skin)but any way I usually put my images directly in the war in my project with subfolder related to their size.
To use the icon I simply do for example btnClear.setIcon("16/clear.png");
With war/images/16.clear.png image folders structure.
You can have a look at getSkinImgDirand do a test

Categories