I am attempting to make a certain image a background image for an application. I know the syntax (android:src="*int*"), at least I think that's it. But I don't know what kind of a source I could use. A directory pointing to a file? A URL?
Why not add/save/move the image to your res> drawable folder and have :
android:src ="#drawable/image"
Related
I use Rich text Editor for uploading images & I create 1 data source for uploading image. When I upload image it is not shown (broken image logo), while I am not publish this image.
What is the problem?
The image is not shown because it cannot be severed for some reason. There could be any number of reasons for this. Here is how I would trouble shoot the issue:
upload an image via the RTE
Right click on the image, inspect element, look at the path to the image
it should say PROTOCOL://SERVER:PORT/static-assets/etc/etc/etc
If the URI doesn't start with static-assets then Crafter's download servlet cannot serve it. You need to fix the path in your datasource.
If the path does start with static-assets then check and see if the image is in your repository at that path specified. You probably won't find it there. If that's the case check your tomcat logs for an error. If the error doesn't help you, post it here and we will go from there.
Environment.getExternalStorageDirectory().getAbsolutePath();
Above code is to get the absolute path of the sd card. But I don't know how to get the storage location of the picture which is taken using in-built camera in android phone.
Can anyone give me a possible code for this question .
It's also in the Environment class. See the javadoc for Environment.DIRECTORY_DCIM. You pass that value to getExternalStoragePublicDirectory() to get the final directory.
Is there a difference between using Picasso to put an image into an ImageView and just using android:src in the xml of the imageview? Right now I have an app that contains about 500 images, and I set them all using android:src in XML. Should I be using Picasso for something like this? Am I wasting precious memory?
Picasso is mainly used to load image from the network. You all your images are resources of your application; you can safely set them in the XML.
I think there may still be some advantages to using picasso even for loading local resources. I think you would still get the caching which might speed up certain operations. For example maybe you get a memory cached image when you switch back and forth between two activities, or scroll in and out of view.
The following is from the Picasso web site. I am thinking Square saw some value in this otherwise I don't know that they would have implemented this.
RESOURCE LOADING
Resources, assets, files, content providers are all supported as image sources.
Picasso.with(context).load(R.drawable.landing_screen).into(imageView1);
Picasso.with(context).load(new File(...)).into(imageView2);
I'm trying to pull the path of a screen image I'm looking at on the android phone of the app im testing. The app shows various pictures. I want to pull the path of the picture to pull the picture name, but have no clue how to start. Any guidance?
edit:
I'm trying to find out if I could pull the path from the app code to see which image the user is viewing. for example. if im looking at an image, I want to know whats the path of the image (path should be coming from someone's harddrive)
there's not necessarily a path for an image. it's better to say the source of the image, be it a file, an HTTP stream, or otherwise. and unfortunately, that info is lost once it's set into an ImageView.
to set the image bits into an ImageView, you construct a Bitmap, usually using one of the decode*() methods in BitmapFactory. that is what determines the source of the image. in your unit test framework, you can get a handle to the ImageView by getting the Activity and calling findViewById(), but that's not going to help you.
there may be other places for you to hook into the code to determine that sources for the image data, but i can't say without knowing your application source code.
you could ask your developers to make the source available in the ImageView's tag (see setTag() / getTag()). that way you could pull it out in your unit tests. of course, you'll have to have an understanding with them as to what the source will be (a URL, a database URI, a file path, ?).
Hey So I'm pretty much awful at java and I want to add a ImageIcon now I've done this before and I even have the images to work the only issue is the program I am making is for University work and when I submit the work it will be submitted online through a .rar file.
So my issue is currently the image's have a huge direct path so i.e.
C:\Users\MY-NAME\Documents\NetBeansProjects\UNI-PROJECT\src\IMAGES\image.png
Since they will be reviewing my work on their work PC or home PC whatever the images wont work for them since it's using my home reference. How can I reference a image so they can open it where ever and the images will still work?
Thanks in advance
-SKENG-
The Java Tutorial on How to Use Icons has a small section explaining how to use Class#getResource() when the image is included with the application - look at the createImageIcon() method and the description that follows it.
You can put your images in the current folder or subfolders and then use the following path (for example):
System.getProperty("user.dir") + "images\pic1.gif"
Simply do not use absolute path, and put the images into a subdirectory where is located your sources or binaries.