I'm using a ListView
as a secondary view in my SlidingPaneLayout
.The main view is a map fragment. The ListView
acts as a menu. The problem is that onItemClickedListener
never gets called on the ListView. Even the list row never gets highlighted on press. it seems that the ListView can't get the focus.
EDIT:
actually, slidingPaneLayout.findFocus()
shows that android.widget.ListView. still no luck on clicking the list items.
Here is my xml
<com.ziz.luke.custom_components.MySlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/slidingpanelayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/contactsList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000" >
</ListView>
<TextView
android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center_horizontal|center_vertical"
android:text="@string/noContacts" />
</RelativeLayout>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</com.ziz.luke.custom_components.MySlidingPaneLayout>
How can I solve this??
I've found the answer. I was using a subclass of SlidingPaneLayout
in which I was overriding
onInterceptTouchEvent(MotionEvent arg0)
I was trying to do the following:
So, I created a boolean inside my subclass called shouldSwipe to be returned from the over-ridden method.
the implementation that caused the problem was :
@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
return shouldSwipe;
}
it caused the problem whenever (shouldSwipe = true) because it tells the system that the touch event already is consumed and prevents it from being propagated.
I solved that using this one:
@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
// TODO Auto-generated method stub
return shouldSwipe ?super.onInterceptTouchEvent(arg0):shouldSwipe;
}
that's it.