title: ListView - Custom Adapter - Database
body: <p>Android 2.3.3</p>
  
  <p>I have a table in database with two columns. I wish to retrieve this data and show them in a ListView having two textviews(first column in first textview and second column in second textview) and repeat this till for all the rows in the database. I have read a few examples on(custom adapter and listview) how to do, but the more I read, the more I get confused.</p>
  
  <p>Can someone give me a head start on how to do this? I can use a dynamic listview, but I wish to do it using the static one.</p>
  
  <p>Here is the Layout of the row in the listview:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal"
      android:paddingLeft="5dp"
      android:paddingRight="5dp"
      android:paddingBottom="5dp"
      android:paddingTop="5dp" &gt;
  
      &lt;TextView
          android:id="@+id/txtView_History_Expression"
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:layout_weight="0.50"
          android:text="Expression"
          android:textColor="#FFFFFF"
           /&gt;
  
      &lt;TextView
          android:id="@+id/txtView_History_Result"
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:layout_weight="0.50"
          android:text="Result"
          android:textColor="#316DA2" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Here is the XML with ListView:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
  
      &lt;TextView 
          android:id="@+id/txtView_History_Header"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" 
          android:text="HISTORY"
          android:gravity="center"
          android:textSize="24dp"
          android:textColor="#316DA2"
          android:paddingTop="10dp"
          /&gt;
  
      &lt;ListView
          android:id="@+id/lvHistory"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" &gt;
      &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I am retrieving the data from database and storing it in a Cursor. I want to read data from Cursor and give those values to the textviews in the listview.</p>