coz you are using the same view object to all the shapes. so only the most
recently created view will have listener. use an arraylist and add the view
to it when ever a shape is created.
and check which view is clicked by using view.isPressed().


On Sun, Mar 21, 2010 at 1:26 AM, Luca Bedogni <[email protected]>wrote:

> Hi
>    I have the following code:
>
>                int x = (int)Math.round(Math.random()*200);
>                int y = (int)Math.round(Math.random()*300);
>
>                View h = new CustomDrawableView(c,x,y);
>                h.setLayoutParams(new ViewGroup.LayoutParams(
>                        ViewGroup.LayoutParams.WRAP_CONTENT,
>                        ViewGroup.LayoutParams.WRAP_CONTENT));
>
>                h.setOnClickListener(new OnClickListener() {
>
>                                @Override
>                                public void onClick(View v) {
>                                        // TODO Auto-generated method stub
>                                        Log.d("VIEW",v.toString());
>                                        v.setVisibility(View.INVISIBLE);
>                                }
>
>                });
>
> inside an Handler, that create every 2 seconds a new ovalShape and add
> it to the Layout.
> Everything works fine, except for the clickListener. In fact, when i
> press one of my shapes on the screen, it will be made invisible only
> the last one, and not what I clicked.
>
> Am I missing something?
> --
> Luca Bedogni
> Freelance Web Developer
> http://www.lucabedogni.it
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]<android-beginners%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>
> To unsubscribe from this group, send email to android-beginners+
> unsubscribegooglegroups.com or reply to this email with the words "REMOVE
> ME" as the subject.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe from this group, send email to 
android-beginners+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to