I wanted to generate a list view using below code. But after running this code the screen just shows a blank screen and the "hello" text which is there in main layout
package com.android.test1;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.Toast;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView;
public class HelloListView extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String a[] = new String[]{"a", "b", "c", "d"};
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, a));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
}
}
and the main layout code is as given below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:text="hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFFFF">
</ListView>
</LinearLayout>