0

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).

Jerry
  • 181
  • 1
  • 12
  • what is that `GetPic`? – Paresh Mayani Apr 10 '13 at 03:22
  • 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. – Jerry Apr 10 '13 at 03:27

1 Answers1

0

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 .

Community
  • 1
  • 1
Sarah
  • 372
  • 3
  • 15
  • no I am not looking for an image-button. I am looking for a button that when pressed, will switch the imageview to display a different image.ok so this is close to what I am looking for, just I don't want to have to hardcode each picture I have from my database. – Jerry Apr 10 '13 at 03:19
  • Ok, I haven't work with android & database together before, but are you going to locate these database in the device itself or linked to external database ?! cause u have said "that takes the path of the pic (from drawable)". In addition you can use switch statement to change the picture once the button is clicked. – Sarah Apr 10 '13 at 17:38
  • so how databases work is that the app creates a local database in /data/_____ in the sd card. could you explain the switch statement a little more? So I use some switch statement to change the image that imageview is using? – Jerry Apr 10 '13 at 17:50
  • so, u meant that the user would import the images that he want from the SD ?! or the application itself has it owns images to represent?! for switch statement, we use switch instead of the nested "if- if else". u can use it to represent the images once the user press the button; eg; we have three images & count var=1 ; once the user press the button case 1 will work; display image1 & increase the count by 1, & so on till reach case 3 the count will reassign to 0 to start again. Ive edited my answer & add switch tutorial. – Sarah Apr 10 '13 at 19:32
  • ok see I don't really want to hardcode every single picture I have in my database. I have would have 100+ cases. No the images are in the database, application has its own images. what I need is a button that will show the next image from the database AND i can press the next button as many times as I want (until I reach my last image). check my edit for an explanation of the function GetPic. – Jerry Apr 10 '13 at 20:16
  • oh, I see.u r right. coding over 100 image would really waste a lot of time. Ok, I can't really help u in the database but for the button I found two things would help you to go through . check the new editing. Sorry for delay :) – Sarah Apr 12 '13 at 11:04