android - How do I add TableRows dynamically? -


i'm trying create new table row , add existing tablelayout. have scoured internet , seems i've tried cant new row show. if add tablerow id in layout , add custom imageview without adding new tablerow layout imageview shows need add new row dynamically. in fragment:

@override public view oncreateview(layoutinflater inflater, viewgroup container,                        bundle savedinstancestate) {   view rootview = inflater.inflate(r.layout.fragment_default_view,    container, false);    final viewgroup tablelayout = (viewgroup) rootview.findviewbyid      (r.id.table_bracket);    tablerow.layoutparams layoutparams = new tablerow.layoutparams(           tablerow.layoutparams.match_parent,           tablerow.layoutparams.match_parent   );    tablerow tablerow = new tablerow(context);   tablerow.setlayoutparams(layoutparams);    separatorimageview separator = new separatorimageview(getactivity());   separator.setlayoutparams(layoutparams);    tablerow.addview(separator);   tablelayout.addview(tablerow);   return rootview; } 

here's layout i'm trying add to:

<framelayout xmlns:android="http://schemas.android.com/apk/res/android"   xmlns:tools="http://schemas.android.com/tools"   android:layout_width="match_parent"   android:layout_height="match_parent"   tools:context="com.mbusby.bracketsandbox.defaultviewfragment">  <tablelayout xmlns:android="http://schemas.android.com/apk/res/android"   android:id="@+id/table_bracket"   android:layout_width="match_parent"   android:layout_height="fill_parent"   android:stretchcolumns="*">  </tablelayout> 

add line after tablelayout.addview(tablerow); line

getwindow().getdecorview().findviewbyid(android.r.id.content).invalidate(); 

to refresh tableview newly added row visible


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -