android: connect database to listview in two ways
<p>i try to connect database to listview, in this sample1 i can but i see the list view on all of </p>

<p>the screen, and i need to see him only on in part of the screen because i have buttons and editbox.</p>

<pre><code>public class BladeActivity extends Activity {
    ListView list;
    SQLiteDatabase db;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.list = new ListView(this);
        this.registerForContextMenu(this.list);
        this.db = this.openOrCreateDatabase("dic_tut5", MODE_PRIVATE, null);
        this.db.execSQL("CREATE TABLE IF NOT EXISTS MEN(value VARCHAR,Name VARCHAR,MyZ VARCHAR);");
        this.update_list();
        setContentView(this.list);
    }

 public void update_list() {
        final ArrayList&lt;String&gt; db_results = new ArrayList&lt;String&gt;();
        Cursor cursor = db.rawQuery("SELECT value,Name,MyZ FROM MEN ORDER BY MyZ desc", null);
        while(cursor.moveToNext()) {
            db_results.add(String.valueOf(cursor.getString(cursor.getColumnIndex("value"))) + " \n " +cursor.getString(cursor.getColumnIndex("Name")) + " \n " +cursor.getString(cursor.getColumnIndex("MyZ")));
        }
        cursor.close();
        this.list.setAdapter(new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,db_results));
        list.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView&lt;?&gt; parent, View view,int position, long id) {
                Toast.makeText(getBaseContext(),db_results.get(position),Toast.LENGTH_SHORT).show();
            }
          });
    }
</code></pre>

<p>and in this sample2 i can see the listview on part of the screen as i need</p>

<pre><code>public class BladeActivity extends ListActivity {
    ListView list;
    SQLiteDatabase db;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String[] items={"AA", "BB", "CC", "DD"};
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        final ListView lstView = getListView();
        lstView.setChoiceMode(0);  
        lstView.setTextFilterEnabled(true);
        setListAdapter(new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, items));

   }
</code></pre>

<p>and the xml file:</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="fill_parent"
    android:layout_height="fill_parent"
    android:background="#580000"   
    android:orientation="vertical" &gt;

    &lt;TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" /&gt;

    &lt;LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" &gt;

        &lt;Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" /&gt;

        &lt;Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" /&gt;

        &lt;Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" /&gt;

    &lt;/LinearLayout&gt;

    &lt;ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="300px"&gt;

    &lt;/ListView&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>how to change sample2 that will work with database like sample1 ?</p>

<p>thanks</p>
