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?

4

3 回答 3

10

只需添加android:clickable="true"到第二个FragmentFrameLayout.SlidingPaneLayout

于 2013-12-19T08:52:33.833 回答
3

Locutus 是正确的。无论顶部的片段是什么,添加属性

android:clickable="true"

所以它不会将点击事件传递给下面的片段。

感谢大家节省了我的时间。这是我的代码。我使用了覆盖布局,但这也适用于常规滑动窗格布局。查看第二个片段,我添加了可点击的 true 属性。

<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>
于 2014-07-17T06:49:53.463 回答
0

我有同样的问题,我认为它是“v4”版本的 Fragment 和 ListFragment 和 SlidingPanelLayout 的组合......如果您将导入从“v4”更改为导入正常的“android.app.ListFragment;” 和“导入android.app.Fragment;” 一切正常。

对不起我的英语不好 ;)

于 2013-10-11T15:12:43.797 回答