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
Related
I am trying to attempt the below :
What i am trying to do is whenever a user click on a button, it will add a image to the layout(which the user can scale and move to any position within the layout). The user can repeat this process hence if the user click 6 times on the button, there should be 6 image in the layout.
i have google around, looking for some sample but ain't sure if its the correct one to use. maybe i did not use the correct keyword to search. So far i have seen is endless adapter and RecyclerView but both seen to be mainly for "ListView" type.
Anyone can suggest or share a link/example that i can read up and learn from? It will be a great help.
If you want to add image on button click set on-click listener on it. You need to get how many time the user have clicked the button.
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
//get adapter and view
//get image to add
addImage(i); //to desire view
}
});
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 :-)
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 .
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.
Friend's,
I have an single image in which it set has screen home page in which it contains 5 menu icons,so i need to know how to set click events for this icons,is't possible set click event for individual icons.
(how to set click events for image have 5 menus has a single image)
I'm unsure what you mean, how are you drawing this image? is it on a canvas or something else? is it a bitmap? if you want individual click events for 1 object and from what I can decipher from your question you have 1 image which contains 5 icons, could you not draw it all on a canvas then set the 5 icons as their own image drawn on top of the background image and then setup individual onClick() events for each?
Then if you're setting them to click in a new Activity just use startActivity()
e.g
Intent myIntent = new Intent(theclass.this, whereyouwanttogo.class);
menu.this.startActivity(myIntent);
Also, if this is a menu is there any reason why you're not just using a menu rather than an image?
http://developer.android.com/guide/topics/ui/menus.html