i want create textviews , put them next each other , if textviews reached end of page, starts below of previous textviews. wrote code putting textviews next each other below:
relativelayout main = (relativelayout) inflater.inflate(r.layout.activity_main, null); relativelayout.layoutparams params = new relativelayout.layoutparams(viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content); for(int i=0; i<10; i++){ textview text = new textview(this); text.settext("text"+string.valueof(i)); text.setid(i); main.addview(text, params); params = new relativelayout.layoutparams(viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content); params.addrule(relativelayout.right_of, text.getid()); } but when textviews reaches end of screen similar this:

how can solve problem?
i think elegant way use adapter view recyclerview. can define max number of items in each row. works listview more features. read here: https://developer.android.com/training/material/lists-cards.html http://blog.sqisland.com/2014/12/recyclerview-grid-with-header.html
Comments
Post a Comment