I have three activities and in my first activity i have 2 imageviews , by clicking each image it is navigating to the next activities. All the three activities contains imageviews. Now my problem is when navigating to the next activity on click, default image is getting highlighted, instead i would like to highlight a specific image of my choice.Help me in achieving this.
Try setting setColorFilter to your view. You can highlight the your specific view.
PorterDuffColorFilter setNewFilter =
new PorterDuffColorFilter(Color.GREEN, PorterDuff.Mode.SRC_ATOP);
ImageView imgSelected = (ImageView)findViewById(R.id.myImage);
Drawable d = imgSelected.getBackground();
d.setColorFilter(setNewFilter)
// Remove the filter by setting it as null.
d.setColorFilter(null);
Finally i found the ans.. It is very simple we need to set request focus on the particular image
img1.requestFocus();
near particular onclick. Hope this may help someone :-)
Related
I've got a questions. I have an OnClick method. So user clicks on button it randomly gens image. So when he finds the similar image and clicks on it I need to do OnClick from the beginning.
No, there is a point:
1.User click on 1 image
2. It generates the second image
3. 3 different images is already on the desk and he needs to find the proper image.
Ok,
If a = b, then do the onClick method for image 1.
Assuming you want the user to click on image to generate new image, then you can use ImageButton for this. Add OnClickListener to this button and change the image in that listener.
Tutorial here
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).
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 .
In the native Gallery app on Android, when Select item via Option Menu action, you can select multiple items, each grid item which will have a colored-border overlay on top signify as selected when clicked.
Question:
How to do this dynamically using getView() in the ImageAdapter
class? (since there is setBackgroundColor() but not setBorder()
Is there a better way to accomplish this? (such as creating a padding
of some sort for the image within the gridview cell, then set the
background color which will look like a border)
I finally decided to use the 2nd method in the original post: creating a padding for ImageView within the gridview cell and set the background color.
I used ImageView.ScaleType.CENTER_CROP with setCropToPadding(true); for the ImageView.
I wanna create android animation like shown on this example. Only one change I need here. I wanna create two button (Previous and Next). I want see next image for clicking next button, and previous- previous button.
Is there a way to this or there is another examples? Thanks
In buttons OnClickListener increment the position of the image that u want to show
imageView.setImageResource(position);
More
UPDATE
imgView.setImageResource(Imgid[position]);
you can get teh current position of the image using the methods available in example u gave.
I really need horizontal scrolling in my app, so I overrode Gallery and I'm trying to do something with an OnItemSelectedListener, and a GestureDetector I'm calling from an OnTouchListener I've set on the Gallery. What I want is to remove the auto-selection of Gallery items as I scroll, but I want to be able to click an item to select it.
If I set an OnClick listener on a view that is populated in the adapter, the Gallery fails to scroll. Also, the OnItemClicked event is never called for the listener I set for that on the Gallery.
To remove selection from all items you should do this:
youGallery.setUnselectedAlpha(1);
Maybe my answer to this question will help you. It's something which wasn't intended to be ever realized...
For your case why dont you just use a HorizontalScrollView. Just put a linear layout inside and add as many imageview's as you need if your using images, or dynamicaly add it in java code.
This will elemenate the selection of gallery by default. This will be easier than trying to Override the Gallery widget default methods.
Why not you set some tag while you click on an item in the Gallery to select.
Now once again when you click after the item is selected just check for the tag that you had set, and based on the condition you can move to new screen and whatever task you want to perform.
But keep one thing in mind, you have to set the tag with every gallery item while building the gallery view.
I hope you will get what I want to say.
If still you have any problem then let me know.
I had the same scenario and I solved that.