i need have resultset result of select query mysql db. how can display in table layout?? have setup layout tableview
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <edittext android:id="@+id/myfilter" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="@string/some_hint" /> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="10dp" android:text="@string/some_text" android:textsize="20sp" /> <tablelayout android:id="@+id/producttablelayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:dividerpadding="@dimen/activity_horizontal_margin" android:scrollbars="horizontal|vertical" android:showdividers="none|beginning|middle|end" > <tablerow android:id="@+id/tablerow1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="top|bottom|left|right" android:paddingtop="@dimen/activity_horizontal_margin" > <textview android:id="@+id/ttt1" android:text="column 1" android:textappearance="?android:attr/textappearancelarge" /> <textview android:id="@+id/ttt2" android:text="column 12" android:textappearance="?android:attr/textappearancelarge" /> </tablerow> </tablelayout> </linearlayout>
i want able add resultset data it. like:
super.oncreate(savedinstancestate); string s = null; setcontentview(r.layout.activity_list_all_products); // show button in action bar. setupactionbar(); context333=this; tablelayout mytable = (tablelayout)findviewbyid(r.id.producttablelayout); try { connect2 = drivermanager.getconnection(logonactivity.url, logonactivity.user, logonactivity.password); statement2 = connect2.createstatement(resultset.type_scroll_insensitive, resultset.concur_read_only); preparedstatement2 = connect2.preparestatement("select article_code,article_desc products limit 4"); resultset2=preparedstatement2.executequery(); resultset2.beforefirst(); while (resultset2.next()) { how add next record here table layout?? }
please help
you can create new views (it seems populating table rows textviews) , populate them results query wish. can create new tablerow
constructor (see documentation).
add views to table row instnace using:
tablerowinstance.addview(viewinstance);
and add tablerow
tablelayout
same way:
mytable.addview(tablerowinstance)
tablelayouts , tablerows both subclasses of view. should research on viewgroup
, view, , how structured. this link provides nice visualizations.
Comments
Post a Comment