what is the parent for the view u r fetching. if its the parent (gridview)
then I think will throw exception.

I did removeviews before

I had <linearlayout android:id="@+id/layout"> imgview1
imgview2</linearlayout>

bascilly oncreate u get reference to lineralayout
using

LinearLayout l=findviewbyid(r.id.layout)

then lets say onclick event of button u call

l.removeviews();


this shud work. you can try working along these lines.

in your case you have to check what is the parent before u try to remove.

This is based on my understanding of your problem. I can be wrong .


On Thu, Mar 18, 2010 at 2:59 PM, tilo1583 <[email protected]> wrote:

> Hi Everyone,
>
> I am very new to Android development, but I am not new to develoment
> of UIs.
> I am trying to run this piece of code.
> Basically, there is a GridView which contains a bunch of  ImageViews.
> To each of these image views I have added this
> onTouchListener as given below. However, the removeView statement
> throws an exception - "Unsupported operation".
> It is important for me to remove this view, because I need to attach
> it to another layout.
>
> Any help is really appreciated!
>
>
> this._pieceTouchListener = new OnTouchListener(){
>                        public boolean onTouch(View v, MotionEvent event) {
>                                 if(view != null)
>                                {
>                                        switch(action)
>                                        {
>                                            case MotionEvent.ACTION_DOWN:
>                                                try {
>
>                                                        ViewGroup vg =
> (ViewGroup)v.getParent();
>                                                        //this line throws
> an exception
>
> vg.removeView(v);
>
>                                                } catch (Exception exc) {
>
>  exc.printStackTrace();
>                                                }
>                                            ......
>                                        }
>                              }
>                        }
>  }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
> To unsubscribe from this group, send email to android-developers+
> 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 Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

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

Reply via email to