Click events on SlidingPaneLayout
Asked Answered
R

3

5

I'm trying to use the SlidingPaneLayout. The left view is a ListFragment and the right view is a detail view. The layout is displayed correctly and I can slide it. But if the detail view is in front of the list and I click on it, the list in the background receives the click.

My layout looks like this:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/sliding_pane_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <fragment android:name="net.name.multiremote.RemoteListFragement"
              android:id="@+id/fragment_remote_list"
              android:layout_width="580dp"
              android:layout_height="match_parent"
              android:layout_gravity="left" />

    <fragment
        android:id="@+id/fragment_remote"
        android:name="net.name.multiremote.RemoteFragment"
        android:layout_width="850dp"
        android:layout_height="match_parent" 
        android:layout_weight="1" />

</android.support.v4.widget.SlidingPaneLayout>

I use this code for setting up the click listener in the ListFragment

@Override
public void onListItemClick(ListView list, View view, int position, long id) {
    iItemClickListener.onListFragmentItemClick(view, position);
}

How can I solve this?

Rudderhead answered 12/8, 2013 at 7:41 Comment(0)
F
10

Just add android:clickable="true" to the second Fragment or FrameLayout in the SlidingPaneLayout.

Firn answered 19/12, 2013 at 8:52 Comment(1)
Just to add a bit more info, the android:clickable="true" needs to be added to the second fragment's layout, not (as I thought initially) to the second fragment's node into the main layoutFusilier
A
3

Locutus was correct. Whatever the fragment on top, add the property

android:clickable="true"

so it will not pass the click event to the fragment below.

Thanks everyone for saving my time. Here is my code. I have used an overridden layout but this works on regular sliding pane layout as well. look at the 2nd fragment, I've added clickable true property.

<com.ironone.streaming.application.MySlidingPaneLayout
        android:id="@+id/pane"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <FrameLayout
            android:id="@+id/pane1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <FrameLayout
            android:id="@+id/pane2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clickable="true" />
    </com.ironone.streaming.application.MySlidingPaneLayout>
Algorithm answered 17/7, 2014 at 6:49 Comment(0)
S
0

I have the same problem, I think it's a combination of "v4" version of Fragment and ListFragment and the SlidingPanelLayout... If you change the import from "v4" to import normal "android.app.ListFragment;" and "import android.app.Fragment;" everything works.

Sorry for my english ;)

Sheltonshelty answered 11/10, 2013 at 15:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.