Wait for click event in a for loop
up vote
0
down vote
favorite
I have an array of images like this:
int fruitList = new int
R.drawable.apple,
R.drawable.orange,
R.drawable.bannana
;
and an ImageView. For every fruit i want to a) populate the ImageView b) wait for click to open a Dialog (Choose fruit name and do something ...) and repeat for next fruit.
I thought of a for loop but doesn't make sense. I need to wait for the click before going to the next fruit.
Any ideas ??
android android-drawable android-dialog
add a comment |
up vote
0
down vote
favorite
I have an array of images like this:
int fruitList = new int
R.drawable.apple,
R.drawable.orange,
R.drawable.bannana
;
and an ImageView. For every fruit i want to a) populate the ImageView b) wait for click to open a Dialog (Choose fruit name and do something ...) and repeat for next fruit.
I thought of a for loop but doesn't make sense. I need to wait for the click before going to the next fruit.
Any ideas ??
android android-drawable android-dialog
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an array of images like this:
int fruitList = new int
R.drawable.apple,
R.drawable.orange,
R.drawable.bannana
;
and an ImageView. For every fruit i want to a) populate the ImageView b) wait for click to open a Dialog (Choose fruit name and do something ...) and repeat for next fruit.
I thought of a for loop but doesn't make sense. I need to wait for the click before going to the next fruit.
Any ideas ??
android android-drawable android-dialog
I have an array of images like this:
int fruitList = new int
R.drawable.apple,
R.drawable.orange,
R.drawable.bannana
;
and an ImageView. For every fruit i want to a) populate the ImageView b) wait for click to open a Dialog (Choose fruit name and do something ...) and repeat for next fruit.
I thought of a for loop but doesn't make sense. I need to wait for the click before going to the next fruit.
Any ideas ??
android android-drawable android-dialog
android android-drawable android-dialog
edited Nov 10 at 18:24
Kling Klang
32k156286
32k156286
asked Nov 10 at 16:56
user2788573
4416
4416
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
- Hold an index for your position along the fruitList
- Set an onClickListener on the Image View.
- Create a Dialog in the onClickListener
Subscribe any clicks in the dialog, and in that subscription change the fruit by incrementing your index (maybe% fruitList.size
?)- In the onClickListener launch the dialog
The key difference between app development and smaller programs is that apps are all event based. A for loop isn't suited for this kind of task.
Thanks man. I ended doing what you said and added an interface and a listener in onDismiss of the dialog to increment the index of the array.
– user2788573
Nov 12 at 17:06
add a comment |
up vote
1
down vote
You can use Carousel view for it. You can use following repositories for it. Choose what you want
- https://github.com/sayyam/carouselview
- https://github.com/Azoft/CarouselLayoutManager
- https://android-arsenal.com/tag/154
- https://medium.com/@lobothijau/create-carousel-easily-in-android-app-with-carouselview-6cbf5ef500a9
This looks like a gallery. I want to display one image at a time, maybe some animation and change it after the AlertDialog has closed
– user2788573
Nov 10 at 17:23
you can customize github.com/sayyam/carouselview as u wish
– Lucefer
Nov 10 at 17:27
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
- Hold an index for your position along the fruitList
- Set an onClickListener on the Image View.
- Create a Dialog in the onClickListener
Subscribe any clicks in the dialog, and in that subscription change the fruit by incrementing your index (maybe% fruitList.size
?)- In the onClickListener launch the dialog
The key difference between app development and smaller programs is that apps are all event based. A for loop isn't suited for this kind of task.
Thanks man. I ended doing what you said and added an interface and a listener in onDismiss of the dialog to increment the index of the array.
– user2788573
Nov 12 at 17:06
add a comment |
up vote
1
down vote
accepted
- Hold an index for your position along the fruitList
- Set an onClickListener on the Image View.
- Create a Dialog in the onClickListener
Subscribe any clicks in the dialog, and in that subscription change the fruit by incrementing your index (maybe% fruitList.size
?)- In the onClickListener launch the dialog
The key difference between app development and smaller programs is that apps are all event based. A for loop isn't suited for this kind of task.
Thanks man. I ended doing what you said and added an interface and a listener in onDismiss of the dialog to increment the index of the array.
– user2788573
Nov 12 at 17:06
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
- Hold an index for your position along the fruitList
- Set an onClickListener on the Image View.
- Create a Dialog in the onClickListener
Subscribe any clicks in the dialog, and in that subscription change the fruit by incrementing your index (maybe% fruitList.size
?)- In the onClickListener launch the dialog
The key difference between app development and smaller programs is that apps are all event based. A for loop isn't suited for this kind of task.
- Hold an index for your position along the fruitList
- Set an onClickListener on the Image View.
- Create a Dialog in the onClickListener
Subscribe any clicks in the dialog, and in that subscription change the fruit by incrementing your index (maybe% fruitList.size
?)- In the onClickListener launch the dialog
The key difference between app development and smaller programs is that apps are all event based. A for loop isn't suited for this kind of task.
answered Nov 10 at 21:42
bkach
6461522
6461522
Thanks man. I ended doing what you said and added an interface and a listener in onDismiss of the dialog to increment the index of the array.
– user2788573
Nov 12 at 17:06
add a comment |
Thanks man. I ended doing what you said and added an interface and a listener in onDismiss of the dialog to increment the index of the array.
– user2788573
Nov 12 at 17:06
Thanks man. I ended doing what you said and added an interface and a listener in onDismiss of the dialog to increment the index of the array.
– user2788573
Nov 12 at 17:06
Thanks man. I ended doing what you said and added an interface and a listener in onDismiss of the dialog to increment the index of the array.
– user2788573
Nov 12 at 17:06
add a comment |
up vote
1
down vote
You can use Carousel view for it. You can use following repositories for it. Choose what you want
- https://github.com/sayyam/carouselview
- https://github.com/Azoft/CarouselLayoutManager
- https://android-arsenal.com/tag/154
- https://medium.com/@lobothijau/create-carousel-easily-in-android-app-with-carouselview-6cbf5ef500a9
This looks like a gallery. I want to display one image at a time, maybe some animation and change it after the AlertDialog has closed
– user2788573
Nov 10 at 17:23
you can customize github.com/sayyam/carouselview as u wish
– Lucefer
Nov 10 at 17:27
add a comment |
up vote
1
down vote
You can use Carousel view for it. You can use following repositories for it. Choose what you want
- https://github.com/sayyam/carouselview
- https://github.com/Azoft/CarouselLayoutManager
- https://android-arsenal.com/tag/154
- https://medium.com/@lobothijau/create-carousel-easily-in-android-app-with-carouselview-6cbf5ef500a9
This looks like a gallery. I want to display one image at a time, maybe some animation and change it after the AlertDialog has closed
– user2788573
Nov 10 at 17:23
you can customize github.com/sayyam/carouselview as u wish
– Lucefer
Nov 10 at 17:27
add a comment |
up vote
1
down vote
up vote
1
down vote
You can use Carousel view for it. You can use following repositories for it. Choose what you want
- https://github.com/sayyam/carouselview
- https://github.com/Azoft/CarouselLayoutManager
- https://android-arsenal.com/tag/154
- https://medium.com/@lobothijau/create-carousel-easily-in-android-app-with-carouselview-6cbf5ef500a9
You can use Carousel view for it. You can use following repositories for it. Choose what you want
- https://github.com/sayyam/carouselview
- https://github.com/Azoft/CarouselLayoutManager
- https://android-arsenal.com/tag/154
- https://medium.com/@lobothijau/create-carousel-easily-in-android-app-with-carouselview-6cbf5ef500a9
answered Nov 10 at 17:14
Lucefer
9661511
9661511
This looks like a gallery. I want to display one image at a time, maybe some animation and change it after the AlertDialog has closed
– user2788573
Nov 10 at 17:23
you can customize github.com/sayyam/carouselview as u wish
– Lucefer
Nov 10 at 17:27
add a comment |
This looks like a gallery. I want to display one image at a time, maybe some animation and change it after the AlertDialog has closed
– user2788573
Nov 10 at 17:23
you can customize github.com/sayyam/carouselview as u wish
– Lucefer
Nov 10 at 17:27
This looks like a gallery. I want to display one image at a time, maybe some animation and change it after the AlertDialog has closed
– user2788573
Nov 10 at 17:23
This looks like a gallery. I want to display one image at a time, maybe some animation and change it after the AlertDialog has closed
– user2788573
Nov 10 at 17:23
you can customize github.com/sayyam/carouselview as u wish
– Lucefer
Nov 10 at 17:27
you can customize github.com/sayyam/carouselview as u wish
– Lucefer
Nov 10 at 17:27
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241241%2fwait-for-click-event-in-a-for-loop%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown