how to choose one image to show in ImageView - java

I have a problem, I want to show one image in ImageView, but I want to give user options to choose from list image (maybe put text somewhere in there).
and maybe save it on firebase database, so when user reopen/restart the app, that image user choose/select before will show somewhere in their profile/activity.
so far I've tried RadioButton, CheckBox, Spinner.
and non of them work, maybe I don't know implement it properly.
I'm hoping someone help me solve this, it's help a lot.
thanks.

Related

Method for "add to list" - Android application?? what method is suitable?

So i'm planning to develop an android application. In one activity, if i were to click a button of add, then it will prompt a user input and store the data. After that, thare would be another "list of item" button, where users can see which item they added and the information they input earlier.
I was thinking of using if.. else statement to check whether the button is click by setting a variable of default status=0 and change to 1 when clicked.
But how am i going to make sure that the functions won get messed up? is there any better suggestion for this? Im a beginner who just started to explore android studio.
Okay, so it is very simple and logical, and here is my best explanation. It's a rather long explanation, but I made it as thorough as possible...If you need any more help, just let me know:
You don't need to do any of that status=0 stuff. Just have an onclick listener:
(androidfromhome.com)
And in the listener, you want to go to another screen with a text input. So, just have an intent in the onClick which takes user to another screen:
(www.devcfgc.com)
Okay, so now you got your second screen right? You're going to want a textview (Change this in the xml) in the middle of the screen, where the user can enter data:
String stuff = TextView.getText();
Note, you will need to initialize the textview:
(androidfromhome.com)
So, now you got the text that the user entered. Just save it in SharedPreferences, and that's it, you have it saved!
http://developer.android.com/reference/android/content/SharedPreferences.html
Read about SharedPreferences in the link above.
So now, you have it saved. If you are going to get a lot of data, you can also save it in a database, which is more advanced stuff, that I don't know how to do. Now, display the saved data on the screen (A new screen, again, using an intent) using the method:
setText();
on your textView object for the next activity. That's it!

How to highlight object on the picture

I set a picture as background in my main activity with some objects like home.gif, car.gif, dog.gif, etc. All object files are transparent.
I want to highlight this objects that user can interact with it.
I could not found examples in web how to get this effect. So I am asking here.
I would be grateful if you could help me.
Thank you for your time and consideration!
Ciao, Szymon
You want to show the border of the transparent images in an activity?
Then in selector of that view you just add a pressed state which has borders set.

How to set image to checkbox from sqlite database?

Is there a way to set image to checkbox from prepopulated sqlite database? Or somehow connect checkbox to an image from database. The problem is that I have to shuffle images from database, and the user needs to select two of 5 images using checkbox (or some other way, but I've come up with nothing but checkbox idea). If I did not have to shuffle images I would simply put a checkbox below every image and I would know what image is selected when I user check a box, but this way I would not know where my images are.
See this: http://vikaskanani.wordpress.com/2011/07/20/android-custom-image-gallery-with-checkbox-in-grid-to-select-multiple
and this How to save images into Database to get a image bitmap from stream.
you can use a adapter to set bitmat into each image in gallery.
I hope this could help you.

View different images depending on what item in my list view I click

I'm fairly new to Android programming and I've got this project I need to finish and I'm currently stuck.
I've got a standard listview in a Menu class with an array containing around 20 different elements. So what I want to do is load images in an imageview depending on which item in the listview I click, and since I'm a beginner the only idea I had was to make a new activity for each imageview which seems like a pretty bad way to do it since I'd need about 20-30 new activities..
To sum things up what I want is:
Code for making ONE activity that will display a different image depending on which item in the listview I click, probably pretty basic coding I want as simple solution as possible.
If possible I'm also looking for a solution that includes an SQLite database that stores the URL of an image and then display it in a single activity, also depending on which item I press in my current listview.
(I hope you understand my needs, and if you need I can also post my current code for the Menu class if it helps you help me) Or you can just show me a different way to make this work, I appreciate every answer! Thanks in advance!
NOTE
And please keep in mind, I'm a noob at Java and Android so keep it rather simple or at least explain what you do.
When you click on a list item, display the image in another view in the same layout, unless you want the image to take up the entire screen real estate. If you want it in the entire screen, go to a new Activity by sending the activity an Intent.
Activities are the "controller" of your application. They interact with the visible UI and the input from the user. You don't need a separate activity for each image, just an activity that's associated with a "place" in the UI (an ImageView) where you'll display the image.
I'd start by adding the images as resources under res/drawable before going on to databases.
You are going to have to do most of this yourself. There really isn't any substitute for taking the time to learn Java and Android. There are several tutorials and Android University classes under the Resources tab in the Developers Guide; I suggest you do all of them.

Android: Set selected icon in GridView

I'm trying to find a way to store the name of an icon in my database, then use that name to let a user select an icon from an ImageView. I've found various guides on ImageViews and Galleries, but none that show how to get/set the selected image by name. The list of available images won't change, but what's that best way to implement this?
check this tutorial, it can give you an Idea of how to do it:
http://www.firstdroid.com/2011/02/06/android-tutorial-gridview-with-icon-and-text/
Good luck.
Adrian.

Categories