I want to have interface like this image

So i create 2 file XML Place and Place1
Code Place.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/filter_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
</EditText>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
Code Place1.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/icon_place"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="7dp"
android:src="@drawable/icon_landscapes" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="10" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="8"
android:orientation="vertical" >
<TextView
android:id="@+id/label_place"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@+id/label_place" />
<TextView
android:id="@+id/label_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label_address" />
</LinearLayout>
<TextView
android:id="@+id/label_Phone"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginTop="5dp"
android:layout_weight="2"
android:gravity="center"
android:text="@+id/label_Phone" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Here is code in activity class:
public class Place extends Activity {
private String DB_NAME = "Danang Travel.sqlite";
String[] from;
int[] to;
ListView lvPlace;
ArrayAdapter<String> adapterPlace;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.place);
EditText filterEditText = (EditText) findViewById(R.id.filter_text);
lvPlace = (ListView) findViewById(R.id.listView1);
lvPlace.setTextFilterEnabled(true);
// **********************************************************************
SQLiteDatabase DB = null;
Intent t = getIntent();
Bundle extra = t.getExtras();
String temp = extra.getString("k");
try {
DB = this.openOrCreateDatabase(DB_NAME, MODE_PRIVATE, null);
Cursor c = DB.rawQuery(
"SELECT Name,Address,Phone FROM ServiceDetail Where SerID = '"
+ temp + "' ORDER BY Name", null);
from = new String[]{"Name","Address","Phone"};
to = new int[]{R.id.label_place,R.id.label_address,R.id.label_phone};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,R.layout.place1, c, from, to);
lvPlace.setAdapter(adapter);
It doesn’t work! I really don’t understand why? Please help me!
I found this working sample code with ListActivity class, very useful for beginner. Just study it properly and implement in your code,
Its simply read data from db and uses ArrayList class to store the values, and ArrayAdapter to set values in ListActivity.