android - The specified child already has a parent and click event -
that code...
for(int i=0;i<siteslist.getpdf().size();i++) { bitmap bmp; url url=null; inputstream is; imageview iv=null; tr=new tablerow(this); tr.setlayoutparams(new layoutparams( layoutparams.wrap_content, layoutparams.wrap_content)); (int j=0;j<2;j++) { iv=new imageview(this); try { s1=siteslist.getthumbnail().get(count); url = new url(s1); count++; conn=(httpurlconnection)url.openconnection(); conn.setdoinput(true); conn.connect(); = conn.getinputstream(); bmp = bitmapfactory.decodestream(is); iv.setimagebitmap(bmp); iv.setlayoutparams(new layoutparams( layoutparams.fill_parent, layoutparams.fill_parent)); iv.setid(ids); int flag=iv.getid(); log.v(".....flag.....",+flag+""); tr.addview(iv); tl.addview(tr,new tablelayout.layoutparams( layoutparams.fill_parent, layoutparams.wrap_content)); ids++; log.v(".....counter...",count+""); iv.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { int a=v.getid(); if(a==0) { toast.maketext(getapplicationcontext(), "0",toast.length_short).show(); } else if(a==1) { toast.maketext(getapplicationcontext(), "1",toast.length_short).show(); } else if(a==2) { toast.maketext(getapplicationcontext(), "2",toast.length_short).show(); } else if(a==3) { toast.maketext(getapplicationcontext(), "3",toast.length_short).show(); } else if(a==4) { toast.maketext(getapplicationcontext(), "4",toast.length_short).show(); } else if(a==5) { toast.maketext(getapplicationcontext(), "5",toast.length_short).show(); } } }); }catch(exception e) { e.printstacktrace(); } } //log.v(".....myids",ids+""); //ids++; }
it show me (1)"the specified child has parent" warning , (2) when click image recognize 0,1,2 on toast.
can me.thanks in advance
regards
arpit
in inner loop loops 0,1 i.e 2 times.
in inner loop adding same tr(tablerow) tl(tablelayout) twice hence giving specified child has parent warning.
you not manipulating ids variable hence getting toast 0,1,2, iv.setid(ids); since inner loop repeats twice check ids variable.
Comments
Post a Comment