I have a ListView with contents as suppose android in 1st row,blackberry in second row and iphone in 3rd row so on now I want to make ListView's whole row clickable but when I click above content of listview row then it performs only click event but I want if I click any where in a row then a click action should be performed.My code for making listview clickable is below:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.listartistspacedetailview);
setListAdapter(new ArrayAdapter(this,R.layout.listitem_layout,R.id.barrio, keywordxmlparsing.array_artistname));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long thisID)
{
Intent i = new Intent(Artistspacedetailview.this, Loadingimagetab.class);
startActivity(i);
}
and ListView tag in xml file is :
<ListView
android:clickable="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_below="@id/horizontolline"
android:cacheColorHint="#00000000"
android:drawSelectorOnTop="false" />
I know this question is old, but it was the first hit for me in google when I was looking for this problem.
This is my solution.
<ListView
android:id="@+id/XXXXXX"
android:layout_width="fill_parent" // Changed from wrap content
android:layout_height="fill_parent" // Changed from wrap content
android:clickable="true" > // This was suggested in other topics
</ListView>
This is old, but to any one else it might help. Set the inflating layout to fill parent and also set to any other item that may be clickable inside the layout to false, such that the list item may get all the focus. Also set the items to focusable false and focusableOnTouch false also.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With