我一直在努力解决我一直遇到的问题。每次将一个项目添加到我的ListView(适配器)时会发生什么,如果我在最后一个项目(它会在一定程度上这样做),我希望它会自动滚动;但是,如果一次添加3个或更多项目,它将不会自动滚动。这是该ListView的XML:我使用找到的fragment尝试了一种解决方法here.我的代码如下:publicvoidaddChat(finalStringtext,finalStringusername){this.runOnUiThread(newRunnable(){publicvoidrun(){globals.chatAdapter.add(DateForm
AndroidListView的transcriptMode是什么?它有什么作用?这一行是为了确保StackOverFlow允许提问。 最佳答案 来自文档:“在转录模式下,列表会滚动到底部以使添加的新项目可见。”http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:transcriptMode编辑:澄清一下,上面的链接是AbsListView,ListView的父类(superclass),属性来自这里。
使用ListView,我可以通过设置轻松实现自动滚动的聊天View:android:transcriptMode="alwaysScroll"在其XML中。RecyclerView中有等效项吗?http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:transcriptMode 最佳答案 RecyclerView似乎没有那个选项。您必须手动滚动。做类似的事情......notifyItemInserted(intposn)