android - Scrolling to a row in a TableLayout Programatically -
i have tablelayout contained in scrollview. tablelayout populated programatically during runtime. table contains flight arrival information. 1 tablelayout has been populated, want able scroll down current time period.
if know want scroll row number 40 of 100 in table, how can this?
here xml of layout. in advance.
<linearlayout android1:id="@+id/linearlayout20" android1:layout_width="fill_parent" android1:layout_weight="1" android:orientation="vertical" android1:background="#000000" android:layout_height="10000dp" android:measurewithlargestchild="true"> <scrollview android1:id="@+id/scrollview1" android1:layout_width="match_parent" android1:layout_height="wrap_content"> <tablelayout android1:id="@+id/arrivalstable" android1:layout_width="wrap_content" android1:layout_height="wrap_content"> </tablelayout> </scrollview> </linearlayout>
this might late answer, can someone. if more closely follow randy's link, you'll see need place scrollview in runnable, otherwise child.gettop() produce 0.
final scrollview sv = (scrollview) findviewbyid(r.id.scrollview1); tablelayout tl = (tablelayout) findviewbyid(r.id.arrivalstable); int index = 40; final view child = tl.getchildat(index); new handler().post(new runnable() { @override public void run() { sv.smoothscrollto(0, child.getbottom()); } });
Comments
Post a Comment