I have a button along with the List View in XML
The Button is for new contact and the list is for the List of Contacts.
1.How to use ArrayAdapter/OnListItemClick on this List View ?
setListAdapter(new ArrayAdapter<String>(Contacts.this, R.id.ListView));
Is This declaration correct ?
2.Is this method correct ?
<?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" >
<Button
android:id="@+id/bAddContact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ADD CONTACT" />
<ListView
android:id="@+id/ListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
Try this to display simple list
This is the way to use adapter.And for getting selected item of
listViewtry this.I think this is what you want. 🙂