Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使滑动面板中的元素侦听单击事件_Android_Android Layout_Android Activity_Android Fragments_Slidingpanelayout - Fatal编程技术网

Android 如何使滑动面板中的元素侦听单击事件

Android 如何使滑动面板中的元素侦听单击事件,android,android-layout,android-activity,android-fragments,slidingpanelayout,Android,Android Layout,Android Activity,Android Fragments,Slidingpanelayout,我已经使用AndroidSlidingPanel库“”创建了一个演示应用程序,子项为textview。问题是,当我试图单击标签面板滑落时,无法单击标签 <com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto" android:id="@+id/sliding_layout" android:layout_width="match_paren

我已经使用AndroidSlidingPanel库“”创建了一个演示应用程序,子项为textview。问题是,当我试图单击标签面板滑落时,无法单击标签

<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="68dp"
sothree:shadowHeight="4dp">

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:text="Main Content"
    android:textSize="16sp" />

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center|top"
    android:text="The Awesome Sliding Up Panel"
    android:textSize="16sp" 
    android:onClick="ClickedOnLabel"
    android:clickable="true"/>

我遇到过类似的帖子“”,但不明白setdragview是什么?它是干什么的


有人能告诉我应该怎么做吗?

两天后,我学到了一个教训,在使用任何库之前,阅读完整的文档并查看演示

如果有人不得不面对类似的问题,我会回答这个帖子

考虑一种情况,我们必须开发一个类似于谷歌地图的工具,当点击谷歌地图中的任何一个标记时,从底部弹出一个面板,上面有商店的描述和街景

为了做到这一点,我们必须从

  • 如果在AndroidStudio中包含库时遇到任何问题,可以按照以下问题中的步骤进行操作

上述步骤将确保只有在您单击id为“title”的文本视图时,面板才会向下/向上滑动

  • 要收听滑动面板上的单击事件,请确保
    android:clickable=true
    设置为布局或元素

  • 为了获得锚定点,即不完全打开面板,而是将滑动面板打开到所需位置,您可以使用以下代码

    SlidingUpPanelLayout slidingUpPanelLayout =   (SlidingUpPanelLayout)
    findViewById(R.id.sliding_layout);
    
                //Setting the achor point to the middle of the screen
    
                slidingUpPanelLayout.setAnchorPoint(0.3f);
    

以防万一,如果有人有同样的问题,并一直在谷歌搜索,这将是一个好的开始:)

有人能帮我解决这个问题吗:)
android:id="@+id/title"
SlidingUpPanelLayout slidingUpPanelLayout =   (SlidingUpPanelLayout)
findViewById(R.id.sliding_layout);

            //Setting the achor point to the middle of the screen

            slidingUpPanelLayout.setAnchorPoint(0.3f);