【发布时间】:2018-01-03 19:51:52
【问题描述】:
我有一个在 listView 中显示多个 webView 的应用程序。我的问题是当我尝试上下滚动 webView 时,webView 不响应我的手指,除非我只使用 3 个手指。当它响应时,它几乎不会上下移动。我发现问题在于 listview 禁止 webView 滚动。我试过使用:
listView.setEnabled(false);
但这对我不起作用。谁能告诉我如何解决这个问题? 这就是我在 listView 中添加 webView 布局的方式。
ArrayList<DefaultCards> cardsList = new ArrayList<>();
cardsList.add(new DefaultCards("Hello Google","https://www.google.com", new WebViewClient()));
CardsAdapter cardsAdapter = new CardsAdapter(this, cardsList);
ListView listView = findViewById(R.id.cards_listview);
listView.setAdapter(cardsAdapter);
listView.setEnabled(false);
这是显示列表视图的布局:
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cards_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
最后,这是将被插入到 listView 中的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:background="@color/colorBackground"
android:padding="5dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardCornerRadius="4dp">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="50dp"/>
</android.support.v7.widget.CardView>
【问题讨论】:
标签: android listview webview adapter