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
Related
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 :-)
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
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 have a listview which has as image and a text.
Bases on conditions i have set two different images for the text views.
To set the images i have used
viewholder.btnFavItem.setImageResource(R.drawable.imagA);
Now on click i want toggle the images. if initially it was image a, i want it to becomes image b.
I have used the onclick listner and not the on item click becoz i need the position of image and the textview.I need the position becoz the textview can have either of the two images.the one that has image a,i want to change that to image b. i am clicking on the image and not the tetxview. i have used a custom adapter which extends base adapter.
in the onclick i am again using
viewholder.btnFavItem.setImageResource(R.drawable.imagB);
In the xml i have used clickable as true and focusable as false.
how do i toggle these images.
What you can actually do is use a tag to your image via setTag(), and compare it with your getTag():
String tag = viewholder.btnFavItem.getTag();if(tag.equals("imagA")){ viewholder.btnFavItem.setImageResource(R.drawable.imagB); viewholder.btnFavItem.setTag("imagB");}else if(tag.equals("imagB")){ viewholder.btnFavItem.setImageResource(R.drawable.imagA); viewholder.btnFavItem.setTag("imagA");}
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.