【问题标题】:Android Child Views inside FrameLayout are Clickable ,How to disable the click of frameLayout child?FrameLayout内的Android子视图是可点击的,如何禁用frameLayout子的点击?
【发布时间】:2014-11-21 14:55:58
【问题描述】:

当我点击 textview 时,它会打开列表项弹出活动,但我设置 textview android:clickable="false" 不起作用,所以如何禁用 FrameLayout 子视图的点击

<FrameLayout        
    android:layout_width="match_parent"
    android:layout_height="wrap_content"            
    android:orientation="vertical">    

    <ListView        
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@null" 
        android:clickable="true"
        android:fadingEdge="none"/>   

    <LinearLayout        
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clickable="false"
        android:orientation="vertical">

        <TextView
            android:id="@+id/textview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clickable="false"
            android:text="Text"/>

    </LinearLayout> 

</FrameLayout>

【问题讨论】:

  • 你在哪里写 TextView 的点击?
  • 我没有向 textview 写入任何点击,但是当我点击 textview 时,点击事件会转到 listview 我不知道为什么会发生这种情况

标签: android android-layout android-framelayout


【解决方案1】:

正如您希望 TextView 与 ListView 一样滚动,上次最好的方法是将该 View 添加为 ListView 的页脚

TextView mFooterTextView = new TextView(mContext);
listView.addFooterView(footerView);

你的 XML 将是

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ListView
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@null"
        android:clickable="true"
        android:fadingEdge="none"/>

</FrameLayout>

【讨论】:

  • textview its opens the list item popup activity 你在哪里写了这段代码。显示你的 java 文件。
  • 弹出活动将仅在列表项 setOnclickListener 上打开
  • listview foreground as textview 这就是问题
  • @sarath 必须使用 FrameLayout 吗?
  • 是的,在 listview 上向下和向上滚动我需要在 framelayout 上显示和隐藏 textview
猜你喜欢
  • 2013-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多