database display in android -
After
I want to display a table from the database with 5 columns with different strings. The best way for me to advance is to Previously I tried with listview, but different string length lines show not coming correctly.
My layout.xml code:
& lt ;? Xml version = "1.0" encoding = "utf-8" & gt; & Lt; LinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: paddingTop = "4dip" Android: paddingBottom = "6dip" Android: layout_width = "fill_parent" android: layout_height = "wrap_content" Android: orientation = "horizontal" & gt; & Lt; TextView Android: id = "@ + id / text1" android: layout_width = "wrap_content" android: layout_height = "wrap_content" /> & Lt; Android: layout_heigh = "wrap_content" android: layout_marginLeft = "40dp" Android: layout_alignParentRight = "true" /> & Lt; Android: layout_heigh = "wrap_content" Android: layout_marginLeft = "40dp" Android: layout_alignParentRight = "true" /> gt; TextView Android: id = "@ + id / text5" android: layout_width = "wrap_content" & Lt; Android: layout_height = "wrap_content" Android: layout_marginLeft = "40dp" Android: layout_alignParentRight = "true" /> gt; TextView Android: id = "@ + id / text7" android: layout_width = "wrap_content" & Lt; TextView Android: Android: Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_margin = "40dp" Android: layout_lagin = "true" /> & Lt; TextView android: id = "@ + id / textView21" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignParentBottom = "true" /> & Lt; / LinearLayout & gt; Java Code:
super.onCreate (Saved InstantState); SetContentView (R.layout.report); From string []; Int [] to; Db.open (); ListView lv = (ListView) findViewById (R.id.listView1); Cursor c = db.getEducationTitle (); While (c.text ()) {// cursor c = db.fdictitimal (); LinearLayout linearlayout = (linear timer) findViewById (R.id.Layout1); TextView edt = (TextView) new text view (getApplicationContext ()); Edt.setText (c.getString (c.getColumnIndex ("col1") + "" + c.getString (c.getColumnIndex ("col2")) + "" + c.getString (c.getColumnIndex ("col3") ) + C.getstring (c.getColumnIndex ("col4") + "" + c.getstring (c.getColumnIndex ("col5")); Linearlayout.addView (EDT); }
Dynamic table layout is your best bet.
Check it out.
Comments
Post a Comment