I got a listview with images and some info overlaying them. I want to make so, that when I tap an image info fades out from ALL OF THE LISTVIEW. then I can scroll images and tap on them for this info. how is it possible to do so?
Try to implement an onClickListener for the image view. When you tap on an image the listener will be called and you can change the view state of the info.
Related
I have 40 ImageViews inside a GridLayout, they have different colors and I want to know if user touched the desirable image or somewhere else(for example if user touched red image). How should I do that?
Set an OnClickListener for each view and store the views. In onClick you can check the view and know what ImageView was clicked. You could also think about changing the type to ImageButtons!
If you have further problems with your Grid not being able to be clicked, check this out: http://cyrilmottier.com/2011/11/23/listview-tips-tricks-4-add-several-clickable-areas/
TLDR: Disable focusing of the views in your layout.
If you manage your images in a collection maybe think about switching to gridview and implement an adapter with an itemClickListener. So depend on which item is clicked do you action.
How GridLayout items come from the Adapter(List/Image) in Android App
Using the FreeFlow, I've setup a little app that shows images. You can view all images, or search for images.
When you search for images, you can click on an image in the results list and it will open that image in fullscreen mode.
But,
I when I've attached an OnClickListener to the images in the search results layout, the layout will not scroll when my scrolling gesture starts at an image. It only scrolls outside of the image (these are very tiny spaces)
How do I fix this problem?
View.OnClickListener consumes the MotionEvent. If you want to react to a user touch (click) use View.OnTouchListener and return false; for the event, this will allow the custom view's listeners to catch the event.
I have retrieved the all the imaged from sd card and displayed in my grid view.On tap on one image icon from the grid it goes to second activity and display that clicked image in the image view.
But now i want to implement that when we flink/swap on image from the second activity then the image should be changed to next/previous.
Please give me solution.
Thanks
What you are looking for is ViewFlipper with GestureDetector. Here are few links which will get you started with.
http://android-er.blogspot.in/2012/02/implement-swiping-page-effect-using.html
And once you understand the concept, make use of answer here.
gesture Detector is used to detect fling events and view flipper to flip to next element.
I have used the Gallery widget to display a set of pictures, but would like to add an image at the end with an OnClickListener that will allow me to add further images to my list.
How can I add something to the right side of a Gallery View?
Will putting the Gallery and a button inside a HorizontalScrollView work? Or is there a better way to do this?
One way I see doing this:
In your adapter you should override the method getCount() and set it so that it return the number of images you wish to display + 1.
In your getView/bindView/newView (depending on which adapter you used) you should check to see if the position you are inflating is == getCount() - 1. if so, you should inflate a view that contains your "Add new image" button. Then you just need to attach your onClick listener to that button and handle the insertion of new images
Will putting the Gallery and a button inside a HorizontalScrollView work? Or is there a better way to do this?
probably not. There is no way for the views to differentiate which touch events should go to the gallery and which to the HorizontalScrollView.
You need to set your Gallery width to be something less than FILL_PARENT, then you can put the ImageButton to the right of it with android:layout_toRightOf="#id/galleryId"
That way both will be on the screen, the "add" button will always be shown and the gallery will be able to scroll to reveal all of the images that are contained in it.
In my application I have a Gallery view and two buttons to scroll it - left and right. Scrolling the gallery by fling also works, and here is the problem: how can I update the states of buttons after the user scrolled the Gallery using fling movements? Is there any callback that tells that Gallery's selected item has changed? Thanks.
There is an onItemSelectedListener that you can use with a gallery. If you use it you'll probably also want to read about setCallbackDuringFling() that can enable/disable the listener while flinging.