当我将 WebView
附加到 ListView
时,WebView
的 onItemClickListener()
停止工作。我知道这是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/