Main.java
-------------------------
package home.customList;
-------------------------
package home.customList;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Main extends ListActivity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String[] countries = getResources().getStringArray(R.array.countries_array);
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,countries));
ListView listView = getListView();//getListView() from ListActivity //public class ListView
listView.setTextFilterEnabled(true);
}
}
main.xml
----------------------------
<?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" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
values/country.xml
------------------------------
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="countries_array">
<item name="bangladesh">bangladesh</item>
<item name="usa">usa</item>
<item name="russia">russia</item>
<item name="england">england</item>
</string-array>
</resources>
main.xml
----------------------------
<?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" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
values/country.xml
------------------------------
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="countries_array">
<item name="bangladesh">bangladesh</item>
<item name="usa">usa</item>
<item name="russia">russia</item>
<item name="england">england</item>
</string-array>
</resources>