In my app, I am letting the user to select a background image(from a gallery of images using Gallery), i.e., on clicking a button, lets say, 'theme', 3-4 images are shown, and the user gets to select one of the images.
Now as soon as he does that, the image should appear at the background of the activity..I am trying to save this choice, by the user, in my database..
but I really have no idea how to proceed, that is, when the 'theme' button is selected, a 'themepick' activity starts, and a gallery of 3-4 images appear...when the user selects an image, this themepick activity is 'finished' and we go back to the initial activity..now in this activity, I am letting the user enter some data(through text fields) . After the user clicks save, the data is going into the database, and is being retrieved well. But i also want to save the path to the selected image(from the themepick activity), to the database, and when I am retrieving all the data and displaying the data(in a separate activity, lets say), the image should come in the background as well.
I tried to elaborate as much as possible.
I urgently need a solution as my submission is due in 2 days.
Thank you!
Use a SharedPreference.
You question doesn't seems to be specific on your problem . If I understood correctly your trying to set a background of an layout on runtime.
You need to find the layout Id and set background as below
View layout= findViewById( R.id.layout);
Bitmap bitmap = BitmapFactory.decodeStream(stream); // your image file stream from a path
BitmapDrawable bg = new BitmapDrawable(bitmap);
layout.setBackgroundDrawable(bg);
Let me know if it helps u.. :)
Related
I am trying to make one activity that will have a specific text and image based on what button was clicked in the previous activity. The first activity is a page with a bunch of different image buttons of different aquatic plants. Depending on which image button is clicked, I want the text and image of the next activity to be a description of the plant and a picture of it.
The question I have is how do I let the plant information activity know which button was clicked so that it knows which text and image to display?
A generic answer will work so I don't think you'll need any of my code, but if you feel you need it, then I'll post it.
Put it as extras in the intent you use to start the new Activity. Either put the exact strings and image uris, or put some identifier that the activity can look at and decide which one to display.
I am setting a background Image in my first activity which fits the complete screen in XML code only.
From the first activity user navigates to another activity which does something from an image selected by a user.
Now, my point is since the app loads an image for the user , is it feasible to remove the background image from first activity. And are there chances of app getting crashed if I don't remove the background image while migrating to the second activity.
What's a good way, both layout- and codewise, to accomplish the following:
Display one or more clickable images on the screen.
By default, the images are default images (duh)
When clicking on them, they change to a specified image
When clicking again, the change back to the default image
I cannot set all the images in the xml layout file(s), since I must be able to programatically set and change the images when clicking, and keep a record of the images on display etc.
In case anyone wonders: Yes, this is supposed to be a simple "memory" game, where I show x images, and click on two of them to display them, and give a result if they're identical.
I would suggest you to use ImageSwitcher, as the view, and setOnClickListener on the ImageSwitcher, to apply image changes on click action.
I use a Gallery view to display set of images in the header part of my application's main page. Now I need to make the Gallery full screen when user click on any gallery image. In the full screen mode it should have the Gallery functionality (Should be able to move between images...). Finally, in the full screen mode, when user click the image, it should go back to normal screen.
It this possible with Android? Please help me.
Unfortunately you haven't told us what you've tried or haven't and thus it's hard to pick a starting point...
How I would do it, might be a little over kill using an added activity but I prefer the organization, but launch a new activity on view click and pass the strings of the paths in a bundle and the index of the one selected. Then create a bitmap or imageview, however you want to do it but make sure it can have a setOnTouchListener. This way you can use the MotionEvent to see if they swiped left or right and navigate through the list of images you passed to the activity as strings.
If you don't feel like doing bundles, you can make a static class that holds all the image information..
I have an app that allows users to select images from the gallery (using an ACTION_PICK intent). I want to allow users to update their selection, by going back into the gallery and making changes. However, when they go back to the gallery for a second/third/etc. time, I want their previous selections to be selected in the gallery... Is there a way to do this?
Thanks for your time.
Do you mean the Gallery app or your own activity containing a gallery of images?
If it's your own activity you can simply store the results of your ACTION_PICK into a shared preference. You can then go through you gallery and mark your items as selected based on those stored preferences.
I hope this helps