android - How to retrieve references of views which are defined programatically -


ideally 1 can retrieve view reference(in xml file) through findviewbyid method. have class have instantiated views

    public view initialise(context context){      private button mboardbuttons[][] = new button[gridsize][gridsize];        private tablerow rowarr[] = new tablerow[gridsize];         private textview minfotextview;         private textview mplayer;         private textview mplayercount;      tablelayout tablelayout1 = new tablelayout(context);         tablelayout.layoutparams tableparams1 = new tablelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content);         tableparams1.topmargin = 0;         tablelayout1.setlayoutparams(tableparams1);          ( int =0 ; < gridsize ; i++){             rowarr[i] = new tablerow(context);             tablerow.layoutparams rowparams = new tablerow.layoutparams(layoutparams.wrap_content,layoutparams.wrap_content);             rowparams.gravity=gravity.center_horizontal;             rowarr[i].setlayoutparams(rowparams);             for(int j = 0; j < gridsize ; j++){                 mboardbuttons[i][j] = new button(context);                 mboardbuttons[i][j].settext(integer.tostring(i)+","+integer.tostring(j));                 mboardbuttons[i][j].settextsize(150/gridsize);                 mboardbuttons[i][j].setmaxheight(450/gridsize);                 mboardbuttons[i][j].setmaxwidth(600/gridsize);                 rowarr[i].addview(mboardbuttons[i][j]);              }             tablelayout1.addview(rowarr[i]);         }           minfotextview = new textview(context);         linearlayout.layoutparams params = new linearlayout.layoutparams(                 layoutparams.wrap_content, layoutparams.wrap_content);             params.topmargin = 5;             params.gravity=gravity.center;         minfotextview.setlayoutparams(params);         minfotextview.settext("info");         minfotextview.settextsize(25);         tablelayout1.addview(minfotextview);           tablelayout tablelayout2 = new tablelayout(context);         tablelayout.layoutparams tableparams2 = new tablelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content);         tablelayout2.setlayoutparams(tableparams2);          tablerow tablerow = new tablerow(context);          mplayer = new textview(context);          mplayer.settext("player: ");         tablerow.addview(mplayer);          mplayercount = new textview(context);          mplayercount.settext(" ");          tablerow.addview(mplayercount);       return tablelayout1;  } 

the above code defined in particular class(lets substitute xml file)

now how retrieve references these view elements in activity class.

is there method similar method findviewbyid retrieving programatically defined view references?

when create them new have reference. save somewhere.

or can use setid() can use findviewbyid later. silly when can save now.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -