简体   繁体   English

如何在Android上禁用ListView的滚动?

[英]How to disable scrolling for ListView on Android?

I have the following question: I have a difficult layout that contain ListView. 我有以下问题:我的布局很难包含ListView。 I need disable scrolling ability for ListView, because it's container (root Layout) have had ScrollView already, and I don't need a scrolls for ListView. 我需要禁用ListView的滚动功能,因为它的容器(根布局)已经具有ScrollView,并且不需要ListView的滚动。 I disable scrolls by android:scrollbars="none", but abilitity for scrolling would stay. 我通过android禁用滚动:scrollbars =“none”,但滚动的能力会保持不变。 I need that if ListView has 10 items that all items will be shown. 我需要,如果ListView有10个项目,那么将显示所有项目。 How can I do it? 我该怎么做?

Can't you just use a LinearLayout with 10 elements instead of the ListView ? 你不能只使用一个包含10个元素而不是ListViewLinearLayout吗? It is not a good idea to have a ScrollView in another ScrollView . 在另一个ScrollView拥有一个ScrollView不是一个好主意。

Why do you still use the ListView? 为什么仍然使用ListView? Create your own Layout for an item and load it several times ( LayoutInflater , .addView(listItem) ). 为项创建自己的布局并加载几次( LayoutInflater.addView(listItem) )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM