Note that there are some explanatory texts on larger screens.

plurals
  1. POdatabase display in android
    text
    copied!<p>I want to display a table from database with 5 columns with various string length.Which is the best way to display that.Thanks i advance.Previously i tried with listview but various string length shows rows not coming correctly.</p> <p>My layout.xml code:</p> <pre><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" /&gt; &lt;TextView android:id="@+id/text3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="40dp" android:layout_alignParentRight="true"/&gt; &lt;TextView android:id="@+id/text5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="40dp" android:layout_alignParentRight="true"/&gt; &lt;TextView android:id="@+id/text7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="40dp" android:layout_alignParentRight="true"/&gt; &lt;TextView android:id="@+id/text9" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="40dp" android:layout_alignParentRight="true"/&gt; &lt;TextView android:id="@+id/textView21" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>java code:</p> <pre><code>super.onCreate(savedInstanceState); setContentView(R.layout.report); String[] from; int[] to; db.open(); ListView lv=(ListView)findViewById(R.id.listView1); Cursor c = db.getEducationTitle(); while(c. moveToNext()) { // Cursor c = db.getEducationTitle(); LinearLayout linearlayout=(LinearLayout)findViewById(R.id.Layout1); TextView edt=(TextView) new TextView(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); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload