转:http://www.cnblogs.com/bjshsqlt/p/3311830.html

If you would like to after you have updated by listAdapter, you want to make sure that the list is scrolled all the way to the bottom,

so that it displays the last element entered in the list. You  can  do this .

Method1:

mListView.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

Method2:

set this attribute in XML

android:transcriptMode="alwaysScroll"

Method3:

if the above two methods fail, you can try this:

you can manually tell the list to scroll to the bottom by setting the list selection to the last row.

private void scrollMyListViewToBottom() {
myListView.post(new Runnable() {
@Override
public void run() {
// Select the last row so it will scroll into view...
myListView.setSelection(myListAdapter.getCount() - 1);
}
});
}

ListView数据更新后,自动滚动到底部(聊天时常用)| Listview Scroll to the end of the list after updating the list的更多相关文章

  1. 数据更新后让ListView自动滚动到底部

    在做聊天界面的时候想要发送新的数据后,listview自动滚动到底部,显示出最新的数据.网上找了两个方法,觉得不错,记录一下. 方法一: 给listview添加下面两个属性 android:stack ...

  2. C# ListBox 自动滚动到底部 方法:

    在ListBox中添加一条记录(ListBox.Items.Add方法)后,滚动条会自动回到顶部.我们可能更希望它自动滚动到底部,简要介绍几种方法. 方法一: this.listBox1.Items. ...

  3. JS + jQuery 实现元素自动滚动到底部,兼容IE、FF、Chrome

    HTML代码: <ul class="tasklog-dialog-ul" id="auto_to_bottom"> <li>删除虚拟机 ...

  4. 界面为ScrollView时打开界面会自动滚动到底部之解决方法

    开发中遇到了这样的一个问题,界面最外层是ScrollView,然后里面有嵌套了一个ListView还有其他可以获取焦点的View,然后每次打开界面都会自动滚动到最底部,经过一番折腾,发现了一个简单的方 ...

  5. 实现当UILable的内容超出其范围后自动滚动效果

    本文主要介绍 [当UILabel的内容超出其自身的宽度范围后,进行互动展示的效果],我们先来看一下Demo的效果图. 实际实现起来并不十分繁杂,在这里,为了开发的效率,我们使用了一个已经封装好的UIL ...

  6. 我的Android进阶之旅------>Android的ListView数据更新后,如何使最新的条目可以自动滚动到可视范围内?

    在ListView的layout配置中添加 android:transcriptMode="alwaysScroll" <ListView android:id=" ...

  7. 我的Android进阶之旅------&gt;Android的ListView数据更新后,怎样使最新的条目能够自己主动滚动到可视范围内?

    在ListView的layout配置中加入 android:transcriptMode="alwaysScroll" <ListView android:id=" ...

  8. Vue中实现聊天窗口overflow:auto自动滚动到底部,实现显示当前最新聊天消息

    在做消息的项目,当有新消息的时候让新消息出现在最底部,此时的box用的是overflow:auto 注意:vue项目需要注意在dom结构渲染完再进行操作 <div class="mai ...

  9. ASP.Net页面刷新后自动滚动到原来位置

    在网上搜索之后总结了三种方式: 1.设置Page中的MaintainScrollPositionOnPostback属性为true A>.页面里有MaintainScrollPositionOn ...

随机推荐

  1. hihocoder第233周

    题目链接 题目描述 给定一个数组a[N],N小于1e5.把数组划分成若干个片段,每个片段的和都不为0,问有多少种划分方法? 方法描述 定义f(i)表示0~i共有多少种划分方式,则$f(j)=\sum_ ...

  2. JAVA操作mysql

    所需jar包:mysql-connector-java.jar 代码: import java.sql.*; import java.util.ArrayList; import java.util. ...

  3. Python学习笔记(十一)—— 函数式编程

    一.函数式编程理念 函数式编程就是一种抽象程度很高的编程范式,纯粹的函数式编程语言编写的函数没有变量,因此,任意一个函数,只要输入是确定的,输出就是确定的,这种纯函数我们称之为没有副作用.而允许使用变 ...

  4. 如何在windows下安装JDK

    1:卸载 A:一定要删除注册表中的 HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft 项 B:最好用安装工具卸载JDK,如果没有的话就删除JDK文件夹然后用Wise Regis ...

  5. Xcode 各版本简介

    1.Xcode 验证 在终端输入 spctl 命令,并带上安装的 Xcode 的路径 $ spctl --assess --verbose /Applications/Xcode.app 之后会看到类 ...

  6. log4j(二)——如何控制日志信息的输出?

    一:测试环境与log4j(一)——为什么要使用log4j?一样,这里不再重述 二:先看栗子再来下结论 import org.apache.log4j.*; import test.log4j.bean ...

  7. MySQL Sleep进程

    MySQL中查询当前的连接数: mysql> show status like '%Threads_connected%'; +-------------------+-------+ | Va ...

  8. JS获取整个网页html代码

    var test=document.getElementsByTagName('html')[0].innerHTML; alert(test);

  9. android开发之interpolator的使用

    android:interpolator Interpolator 被用来修饰动画效果,定义动画的变化率,可以使存在的动画效果accelerated(加速),decelerated(减速),repea ...

  10. 路径不对 导致FileNotFoundError: [WinError 2] 系统找不到指定的文件, 问题解决办法

    执行python + selenium 代码 from selenium import webdriver driver = webdriver.Chrome("D:\AutoConf\bi ...