I am using GridView using AdapterView. Therefore, I cannot remove Views from the grid view,http://developer.android.com/reference/ android/widget/AdapterView.html So, this technique is not going to work. Do you know any other technique/ work around to remove views from an adapter view?
- Tilo On Mar 19, 2:59 pm, social hub <[email protected]> wrote: > LinearLayout pa=(LinearLayout)la.getParent(); > if(pa!=null){ > Log.i(TAG,"removed view la parent====>"); > pa.removeView(la); > mNetworkLayout.removeView(la); > } > > this one works for me. > > but u should know ur parent first > > lets say ur child parent is linearLayout then cast the parent to > linearlayout of your child > > LinearLayout ll=(LinearLayout)child.getParent(); > > if (ll ! =null){ > ll.remove(child) > > } > > I am not sure if it works for you let me know > > > > On Fri, Mar 19, 2010 at 9:12 AM, tilo1583 <[email protected]> wrote: > > I tried your method, but it still does not work. > > > GridView g = (GridView)findViewById(R.id.gridview1); > > g.removeAllViews(); > > > It still gives the same exception, as 'removeAllViews() is > > unsupported' > > > On Mar 18, 5:36 pm, social hub <[email protected]> wrote: > > > 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%2Bunsubs > > > > [email protected]><android-developers%2Bunsubs > > [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]<android-developers%2Bunsubs > > [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.

