android - Not removing particular item in Arraylist -


enter image description here have edittext imageview plus .

  1. on click of imageview plus i'm inflating new layout edittext , imageview minus.

  2. now, on click of imageview minus. want remove inflated layout. how this?

    arraylist<view> viewlist; /* inflating new layout */ case r.id.ivplus:     layoutinflater layoutinflater = (layoutinflater) getbasecontext()             .getsystemservice(context.layout_inflater_service);     addview = layoutinflater.inflate(r.layout.add_edit, null);     viewlist.add(addview);     ll.addview(addview);     break; /* removing inflated layout */ (int = 0; < viewlist.size(); i++) {     final int j = i;     imageview minus= (imageview ) viewlist.get(j).findviewbyid(r.id.ivminus);     minus.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view v) {              linearlayout extra_add = (linearlayout) findviewbyid(r.id.lin_add);              extra_add.removeviewat(j);         }     }); } 

try this, replace method , enjoy

@override public void onclick(view v) {     switch (v.getid()) {     case r.id.button_add:         layoutinflater layoutinflater = (layoutinflater) getbasecontext()                 .getsystemservice(context.layout_inflater_service);         view addview = layoutinflater                 .inflate(r.layout.inflate_layout, null);         viewlist.add(addview);         lin_layout.addview(addview);         button remove = (button) addview.findviewbyid(r.id.button_remove);         remove.setonclicklistener(new view.onclicklistener() {              @override             public void onclick(view v) {                 lin_layout.removeview((view) v.getparent());                 viewlist.remove((view) v.getparent());             }         });         break;     }  } 

hope helps , enjoy work.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -