This week's book giveaway is in the Spring forum.
We're giving away four copies of Java Persistence with Spring Data and Hibernate and have Cătălin Tudose on-line!
See this thread for details.
Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

ToggleButton and Taking/Displaying Pictures

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Bartender
Posts: 598
26
Oracle Notepad Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 598
26
Oracle Notepad Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Hang a left on main. Then read this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic