在Android的列表视图工作如何滚动? [英] how does scrolling in android listview work?

查看:128
本文介绍了在Android的列表视图工作如何滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android的应用程序在一个活动列表视图。 ListView中有,如果我把它称为是这样,三个数据状态。

I have an android-app with a listview in an activity. The listview has, if I call it so, three data states.


  1. 从没有INET加载的数据 - >只有一个虚拟项目是可见的,他说,数据加载;

  2. 数据加载,并在列表中显示;

  3. 一个列表项被点击,现在显示了这个列表项(所以它是在它的高度增加)的详细信息。

在每个状态改变(1 - > 2,2 - > 3),我称之为notifyDataSetChanged()这个ListAdapater。
这将导致列表视图向下滚动到最后一个项目。这是第一次转型丑陋,甚至在第二个比较难看,因为点击列表项,现在是失焦。

On every state change (1 -> 2, 2 -> 3), I call notifyDataSetChanged() on this ListAdapater. This causes the listview to scroll down to the last item. This is ugly in the first transition and even more ugly in the second because the clicked list item is now out of focus.

我所看到的,出现这种情况与谷歌G1采用Android 1.6。用相同的SDK的行为像期望的(我会尽量多用一些装置来弄明白)。

As I can see, this happens with a google g1 with android 1.6. An htc touch with the same sdk acts like desired (I will try to figure it out with some more devices).

要避免这种情况,我想读出getScrollY(),并设置这个值了。但这种返回0。原因我已经在其他问题上的计算器发现了这个返回值。

To avoid this, I tried to read out getScrollY() and set this value back. but this returns 0. The reason for this return value I already found on stackoverflow in other questions.

有其他人看到这个问题?为什么列表视图滚动到最后一个项目?有人提到,列表视图跟踪滚动位置的。但它似乎在我的情况不一样。

Has anyone else seen this problem? Why does the listview scroll to the last item? It was mentioned that listview keeps track of the scroll position. but it seems that it does not in my case.

也许我打电话了错误的刷新方法?是notifyDataSetChanged正确的?

Or maybe I am calling the wrong refresh method? Is notifyDataSetChanged the correct one?

推荐答案

我相信你想要的:

listview.setTranscriptMode(ListView.TRANSCRIPT_MODE_DISABLED);

这篇关于在Android的列表视图工作如何滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆