• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ToggleButton and Taking/Displaying Pictures

 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a ToggleButton (ON/OFF), two buttons (PicButton and NextButton) and an ImageView.

Toggle ON: Clicking PicButton will ask you to pick 4 pictures (either with camera or from gallery); ImageView remains blank.

Toggle OFF: Clicking PicButton will display the first of the 4 pictures in ImageView. Clicking NextButton will show the next picture (of the 4).

At the moment, I have a ToggleButton and a boolean associated with its state. My PicButton prompts the user to take a picture with the camera or choose one from gallery and displays it in the ImageView via the URI. My NextButton does nothing.

I don't necessarily need code, but can anybody give me an idea how to go about taking this 'array' of pictures and being able to scroll through them? A thought of mine was to have an ArrayList and add to it every picture taken/chosen, but I've run into logical problems with it (i.e. how to scroll through the ArrayList).
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming your ToggleButton is working as intended, this is only a question about controlling data used for the ImageView.

Controlling an array is really easy after setting up an ArrayAdapter. If you would like some examples, there are plenty, so just google android imageview arrayadapter and one ought to fit your style.
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Tkatch wrote:Assuming your ToggleButton is working as intended, this is only a question about controlling data used for the ImageView.

Controlling an array is really easy after setting up an ArrayAdapter. If you would like some examples, there are plenty, so just google android imageview arrayadapter and one ought to fit your style.


I can only find examples of an ArrayAdapter being used for ListViews. Do you mind going into a little more detail for me or directing me to a more specific resource? Thanks for your help.
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
L Vasquez wrote:I can only find examples of an ArrayAdapter being used for ListViews. Do you mind going into a little more detail for me or directing me to a more specific resource? Thanks for your help.

I have little to no experience with them outside of the examples in a book i read, but i am willing to learn it with you.

IIUC, there is essentially no difference between the two, as an ArrayAdapter has specific methods for add, edit, delete, and list. Perhaps you can write the Adapter as if it were for a ListView (using the examples), and once it is working, switch it to an ImageView. Though, the ListView has controls to switch automatically, the ImageView does not, so you will have to change the source and refresh the image manually. Hmm...perhaps that obviates the need for the ArrayAdapter.

Oh! You can use a custom ListView to use images. I remember trying that once. The custom part means that instead of the ListView just showing text, you can define the repeated fragment inside it, and that can contain an ImageView. Let's find some examples: custom ListView ImageView

Does that make sense to you?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic