在将一个元素添加到与listview关联的arrayadapter之后,我试图平滑地滚动到列表的最后一个元素.问题是它只是滚动到一个随机位置
arrayadapter.add(item);
//DOES NOT WORK CORRECTLY:
listview.smoothScrollToPosition(arrayadapter.getCount()-1);
//WORKS JUST FINE:
listview.setSelection(arrayadapter.getCount()-1);
Run Code Online (Sandbox Code Playgroud) android listview selection smooth-scrolling android-arrayadapter
我有一个带有编辑文本的ListView和它下面的按钮.当我单击listView项时,键盘出现并向上推动编辑文本和按钮.我希望列表滚动到所选项目.任何的想法?谢谢
我有一个自定义适配器用于ListView设置并正常工作.在按钮上单击基础数据中的某些内容,因此需要notifyDataSetChanged来刷新ListView.精细.但我也希望ListView滚动到发生更改的行.为此,我在notifyDataSetChanged之后立即调用smoothScrollToPosition.那是行不通的.
如果我不调用notifyDataSetChanged然后滚动工作,所以通知阻止滚动.我可能正在与将来处理的事件进行斗争.任何人都可以给我一个关于出错的指针吗?
我想知道什么时候BaseAdapter.notifyDataSetChanged()完成,然后做声音.我的代码:
BaseAdapter.notifyDataSetChanged();
mScroller.startScroll(oldX, 0, dx, 0);
Run Code Online (Sandbox Code Playgroud)
mScrollernotifyDataSetChanged()完成之前滚动 .我想在完成后mScroller滚动到.oldXnotifyDataSetChanged()
请帮帮我,谢谢.
我在listview上经历了平滑滚动的奇怪行为.我有30个项目在列表中.当我顺利滚动通过
listview.smoothScrollToPositionFromTop(29, 0);
Run Code Online (Sandbox Code Playgroud)
屏幕末尾会有一些额外的空间.实际上listview转移了一点.附图如下.但如果我手动滚动,将没有空间.可以采取哪些措施来解决此问题?
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_orange_light">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我想点击屏幕上的控件并让ListView滚动,直到给定的行位于屏幕的顶部,这一功能在iOS中看起来非常简单.
我没有找到API在这样的方法:http://developer.android.com/reference/android/widget/AbsListView.html#smoothScrollToPositionFromTop(int,INT)然而,这是API等级11,蜂窝.这意味着手机在冰淇淋三明治之前不能使用它,并且将冰淇淋三明治设置为运行应用程序的最低要求是很长的时间.
有没有办法在Froyo中获得相同的功能?