button click shows next picture from database in android - android

So I have been scratching my head and trying to figure out how to do it.
TO give some more info:
I have a gridview with a bunch of pictures taken from a database. When someone clicks a picture, a new activity starts and there is an imageview that shows that same picture that was clicked. The above I have already coded except for the button that can change the imageview.
Now I would like to implement a button that basically shows the next picture from the database (or the next picture to the right from the gridview).
I am looking for a button that when pressed, will switch the imageview to display a different image from my database.
I have tried to use imageswitcher, viewswitcher, and some other things but to no avail.
I have a function called "GetPic" that takes the path of the pic (from drawable) clicked so it can show it in the imageview in the new activity.
if any other info is needed, i'll gladly share it.
thanks!
EDIT: getpic is my function that grabs the drawble path from the database. If I put (GetPic(activity_here.pos)) activity_here.pos will give GetPic the position from the gridview (which picture was selected) and then GetPic spits out the path the the picture selected so it can be shown in the imageview
if I do (GetPic(activity_here.pos+1)) this will show the next picture (which is what I want) just if I make the button simply add one to the position, I have to turn my imageview in to "final" so I can only get the next picture once(i don't want), not until I have run out of pictures to show(i want).

Check this : Android: ImageSwitcher
Also this would help you as well: https://www.youtube.com/watch?v=Jc11oWIjz-w
& don't forget the third part. Good luck .

Related

How to persist the image selected from gallery on the layout even if we returned to the activity again?

I have relative layout in which i have an image view.I am selecting an image for it from the gallery.I used intent to go to other activity.When i returned to the first activity,my image from the gallery was not there.I want to display the gallery image on the screen even if i returned to the activity.please help me.
Bitmap represent any view by using pixel.I don't understand Why did you use it for textview.
You can use textview inside relative layout and set the text which is coming from intent by using ".setText()" method.

separate click on each item in android

The question might be duplicate ..sorry for that.
I have an activity (test activity) and array adapter (test array) for same.
The list contains image and text. but the image is not displayed always. It has some condition. So look is like
---------------------------------------
image1 text1
test2
test3
image4 test4
---------------------------------------
So test activity display the above list on screen.
Now i want to do different screen load on image (image activity) and text (text activity).
As the on-click handler will be in separate file (test array) i am not sure how to return to test activity and to specific task.
actually i have a list view with image and text.
Below are some scenario
Image will not be present on each row.
If image is present then Onclick of image shown other screen (for example image activity).
if user click other than image that is text show text activity screen).
What i have done is i have a list click handler in a separate file that is ArrayAdapter so i cant't do image click listener there.
So the issue was how to identify which row image is clicked?
Solution:
After lots of R&D and code changes i done below and its working:
I have added android:onClick="ImageClickHandler" for image click in xml.
and during row creation i have set row position as Id.
So when clicked on image you can get position by view.getId(), so u have the position when u click on image and hence you can get complete data on that row.
Might be there is another way....but this is what work for me.

How to return to method, android;

I've got a questions. I have an OnClick method. So user clicks on button it randomly gens image. So when he finds the similar image and clicks on it I need to do OnClick from the beginning.
No, there is a point:
1.User click on 1 image
2. It generates the second image
3. 3 different images is already on the desk and he needs to find the proper image.
Ok,
If a = b, then do the onClick method for image 1.
Assuming you want the user to click on image to generate new image, then you can use ImageButton for this. Add OnClickListener to this button and change the image in that listener.
Tutorial here

How to populate gridview with image just selected from gallery or captured from camera

I have Image Gridview and I want to add images ONE by ONE to gridview selecting from gallery or image captured from camera.
What you can do in your case is always have an image assigned to the last item of your Grid View.
Clicking on that last item you can create a popup asking for you to take it to you gallery or for camera.
Now if the user clicks on back button or decides to cancel keep showing that last populated '+' sign image in your grid view else if any other option is opted you can navigate to the desired action by having in an onActivityResult().
if the result code is positive and you may continue with:
1) Delete the last item from grid view i.e, the '+' sign image
2) Appending the image either taken from camera or gallery
3) Appending the image having '+' sign itself
And always put a condition for the last item of your grid view to point it to the dialog for Navigating to gallery or Click from camera.
For other items you may continue with your desired requirements.
Let me know if it helped.
Thanks

android gallery animation with buttons

I wanna create android animation like shown on this example. Only one change I need here. I wanna create two button (Previous and Next). I want see next image for clicking next button, and previous- previous button.
Is there a way to this or there is another examples? Thanks
In buttons OnClickListener increment the position of the image that u want to show
imageView.setImageResource(position);
More
UPDATE
imgView.setImageResource(Imgid[position]);
you can get teh current position of the image using the methods available in example u gave.

Categories

Resources