Android的可扩展的ListView自动滚动至底部,当我点击组当我、Android、ListView

2023-09-07 00:34:06 作者:你管我帅不帅又没让你爱

我有一个装满物品的ExpandableListView。当你点击一个项目在顶层它开辟了一个新的水平,显示一个包含每个项目的一些额外信息的列表。对于一些顶级项目(组),当我点击他们就打开了底部的项目(儿童),并没有别的。但是当我点击他们来说,开辟了儿童和滚动我一路下来到该组的最后一个子等团体。没有人知道为什么它这样做了一些项目,而不是别人?而有没有办法摆脱这种效果,只是离开滚动到同一位置的已经列表?

I have an ExpandableListView that is filled with items. When you click on an item on the top level it opens up the next level which shows a list that contains some additional information about each item. For some of the top items(groups) when I click on them it opens up the bottom items(children) and does nothing else. But for other groups when I click on them it opens up the children and scrolls me all the way down to the last child of that group. Does anyone know why it does this for some items and not others? And is there any way to get rid of this effect and just leave the list scrolled to the same position its already in?

编辑: 我才意识到它这样做滚动只为底部在顶层的项目一半。也就是说,有14个项目中的顶尖水平,为项目8-14当你点击它们就向下滚动,以使最后一个孩子是在屏幕的底部。如果你点击的项目1-7的孩子敞开心扉,没有什么事情发生。

I just realized it does this scrolling only for the bottom half of the items in the top level. That is, there are 14 items in the top level, for items 8-14 when you click on them it scrolls down so that the last child is on the bottom of the screen. If you click on items 1-7 the children open up and nothing else happens.

EDIT2:@coldForged据我所知,我使用的是标准的ExpandableListView 这里是从我的布局XML:

@coldForged as far as I know I am using a standard ExpandableListView here is the xml from my layout:

<ExpandableListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
android:background="@drawable/paper"
android:scrollingCache="false"

android:scrollbars="none"
>
</ExpandableListView>

请问scrollingCache =false属性会导致什么呢?我必须设置该属性得到它显示即使在列表被滚动的背景图像。如果没有这个属性列表背景变为黑色,同时其滚动。

Could the scrollingCache="false" attribute be causing this? I had to set this attribute to get it to show the background image even while the list is being scrolled. Without this attribute the list background turns to black while its scrolling.

推荐答案

我面临同样的问题,找到了非常简单的解决方案在这里:Android的ExpandableListView滚动到扩大集团的立场]

I was facing the same problem and found the really simple solution here : [Android ExpandableListView Scroll to Expanded Group Position]

编辑:由于链接每月一次在这里很简单的解决方案死: 只需设置安卓transciptMode =已禁用。这prevents滚动到最后一个列表中的位置。

Since the link dies once a month here the really simple solution: Just set the android:transciptMode="disabled". This prevents the scroll to the last list position.

有关进一步阅读:成绩单模式的Andr​​oid文档