【问题标题】:WebView is blocking my ExpandableListView's expansionWebView 阻止了我的 ExpandableListView 的扩展
【发布时间】:2014-10-20 13:47:12
【问题描述】:

我之前一直在使用 ExpandableListViews,我知道复选框、按钮等。

对于可以在 XML 上找到的任何这些小部件(将用作我们列表的 groupView)中的任何一个,必须将 setFocusable 设置为 false,否则,单击组单元格不会展开组,因为这些小部件会窃取关注它。

但是,如果我将 WebView 放在我的 GroupView 中,并且 setFocusablesetFocusableInTouchModefalse,我仍然会 NOT strong> 能够扩大群体。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="horizontal"
   android:layout_width="match_parent"
   android:layout_height="91dp"
   android:background="#ffffff">

<ImageView
   android:layout_width="30dp"
   android:layout_height="91dp"
   android:id="@+id/sth_cell_img_correct"
   android:layout_marginLeft="10dp"
   android:layout_marginRight="10dp"
   android:src="@drawable/icon_checked" />

<WebView
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:layout_marginRight="20dp"
   android:focusable="false"
   android:focusableInTouchMode="false"
   android:id="@+id/webView2" />
</LinearLayout>

但是,如果我从 XML 中删除 WebView,我可以毫无问题地展开/缩小单元格。

我必须在这里做一些其他的事情。其他一些属性应该设置为 false 或类似的,但我无法弄清楚究竟是什么。

有没有人知道如何在组 XML 中使用 WebView 并能够扩展组本身?

【问题讨论】:

  • 你为什么需要一个 WebView ......你想在这里用 Web 视图做什么......

标签: android webview expandablelistview


【解决方案1】:

尝试在根元素上设置此项

android:descendantFocusability="blocksDescendants"

然后使 WebView 不可点击

android:clickable="false"

最终的 XML 应该是这样的:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="91dp"
android:descendantFocusability="blocksDescendants"
android:background="#ffffff">

<ImageView
    android:layout_width="30dp"
    android:layout_height="91dp"
    android:id="@+id/sth_cell_img_correct"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:src="@drawable/icon_checked" />

<WebView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="false"
    android:id="@+id/sth_web_view" />
</RelativeLayout>

希望这会有所帮助。

【讨论】:

  • 你,先生,是个巫师!
  • 拯救了我的一天@pixelsize
猜你喜欢
  • 2014-12-29
  • 2013-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多