android - SlidingPaneLayout 上的点击事件

标签 android android-layout slidingpanelayout

我正在尝试使用 SlidingPaneLayout。左 View 是 ListFragment,右 View 是详细 View 。布局显示正确,我可以滑动它。但是如果详细 View 在列表前面并且我点击它,后台的列表会收到点击。

我的布局是这样的:

<?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>

我使用这段代码在 ListFragment 中设置点击监听器

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

我该如何解决这个问题?

最佳答案

只需将 android:clickable="true" 添加到 SlidingPaneLayout 中的第二个 FragmentFrameLayout 即可。

关于android - SlidingPaneLayout 上的点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18181749/

相关文章:

android - Seekbar 拇指图像被截断

android - 该效果的名称/重现方法

android - 如何设置滑动面板默认状态折叠和折叠面板最小高度?

java - 将 SlidingPaneLayout 的触摸事件限制在屏幕的最左边缘

java - Libgdx Pixmap drawCircle 正在绘制

android - catchbackkey 不工作 (libgdx) Android

android - 为什么 R 不存在错误出现在 android 中?

Android 不同的屏幕尺寸

android - 如何在一个布局中实现多个recyclerviews?

java - 重新创建 Activity 后恢复 fragment