I have a simple row model and a ListView in a Fragment; the ListView gets properly populated, with all the correct dimensions, colors, etc. Problem is, clicking on a row fires no event.
The code in my fragment is:
MyAdapter mAdapter = new MyAdapter(getActivity().getApplicationContext(), R.layout.list_row, strings);
mList.setAdapter(mAdapter);
mList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d("LIST", "Selected item # " + position);
}
});
The fragment layout (a piece of it) is:
<ListView
android:id="@+id/m_list"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_margin="20dp"
android:clickable="true"
android:longClickable="true">
</ListView>
The row layout is:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView
android:id="@+id/txt_surname"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:text="@string/surname"
style="@style/ListStyleXLarge"/>
<!-- 4 more TextView just as the first one -->
</LinearLayout>
The style is simply:
<style name="ListStyleXLarge">
<item name="android:textSize">
@dimen/text_size_large
</item>
<item name="android:textStyle">
bold
</item>
<item name="android:textColor">
@color/list_item_text_color
</item>
</style>
What can fix this problem? I have already tried to set the
android:clickable="false"
android:focuseable="false"
android:focuseableInTouchMode="false"
to all of the TextViews, but nothing so far.