android - 我的 ListView 的 onItemClickListener() 在添加 WebView 时不起作用?

标签 android webview android-listview focus onitemclicklistener

当我将 WebView 附加到 ListView 时,WebViewonItemClickListener() 停止工作。我知道这是WebView的焦点问题。但是我设置:

  • WebView 的 xml 中:

    android:clickable="false"  
    android:focusable="false"  
    android:focusableInTouchMode="false"
    
  • 以及在适配器类中:

    webview.setFocusable(false);     
    webview.setFocusableInTouchMode(false); 
    webview.versedata.setEnabled(false); 
    webview.setClickable(false);
    
  • 也在主要 Activity 中:

    listview.setItemsCanFocus(false);
    

但我的 onItemClickListener() 仍然无法正常工作。有什么建议吗?

最佳答案

to add your xml main layout

android:descendantFocusability="blocksDescendants" 

Example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:auto="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:descendantFocusability="blocksDescendants">

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<WebView  
    android:layout_width="fill_parent"`
    android:layout_height="wrap_content" />
</LinearLayout>

</LinearLayout>

关于android - 我的 ListView 的 onItemClickListener() 在添加 WebView 时不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14931881/

相关文章:

android - MongoDB:如何在 MongoDB 中设计 Twitter 风格的关注者/关注关系模型?

android - 通过网络请求回填时从 Room 发出协程流

Android:setOnItemClickListener 不适用于软键盘中的 ListView

Android:从 ListView 访问 subview

Android,通过页脚停止重叠 ListView 项目

android - 改造中的多个排队导致内存不足错误?

android - 如何将从地理标记图片中提取的 gps 坐标格式 (DMS) 转换为十进制格式?

javascript - 如何以类似的方式从 javascript 快速调用 android 和 iOS 中的函数

javascript - 在没有 webRTC 的情况下访问相机或网络摄像头

android - touch html 5 canvas 麻烦