android - How to retrieve the position each view within a Gridlayout -
im new android , im wondering if there standard method used accomplish retrieval of views' positions in gridlayout.
i'm dynamically adding , removing views gridlayout this
addbutton.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { addbutton.setvisibility(view.invisible); button newbutton = new button(layoutanimationsbydefault.this); gridcontainer.getcolumncount(); newbutton.settext(string.valueof("position#"+"huh")); newbutton.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { gridcontainer.removeview(v); addbutton.setvisibility(view.visible); } }); gridcontainer.addview(newbutton, math.min(-1, gridcontainer.getchildcount())); } });
i've tried this..
addbutton.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { addbutton.setvisibility(view.invisible); button newbutton = new button(layoutanimationsbydefault.this); object tag =v.gettag(); if(tag!=null) { int position = (integer)tag; log.v("onclick", "position: " + position); newbutton.settag(position); newbutton.settext(string.valueof("position#"+position)); textview text1 = (textview) newbutton; string message = "positionis" + position + text1.gettext().tostring(); toast.maketext(layoutanimationsbydefault.this, message, toast.length_long).show(); } newbutton.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { gridcontainer.removeview(v); addbutton.setvisibility(view.visible); } }); gridcontainer.addview(newbutton, math.min(-1, gridcontainer.getchildcount())); gridcontainer.getcolumncount(); }
this creates new button,but nothing inside, not text or anything
im trying figure out how update , retrieve updated position of each view in gridlayout, each time item added, removed re-arranged in gridlayout.
by position don't mean x,y coordinates, 0,1,2,3,4 position seen in listviews.
i've tried getcolumncount(); getchildat(); actionlistener() actionperformed() etc. help, pointers, hints?thanks!!
Comments
Post a Comment