ListView控件不滚动到年底,键盘使用时, [英] ListView doesn't scroll to end, when keyboard using
问题描述
我的ListView应自动滚动到最后,当接收或发送新邮件。 但是,当我使用Android键盘从EditText上发送一条信息,ListView的,ListView的调整和新的消息,我想送,出现了画面,我必须向下滚动才能看到它,即使键盘消失和ListView再次调整大小。
My ListView should automatically scroll to end, when new message received or sent. But when I use Android keyboard to send message from EditText below ListView, ListView resized and new message, which I want to send, appears out of screen and I have to scroll down to see it, even if keyboard disappears and ListView resizes again.
要滚动的ListView我使用:
To scroll ListView I use:
listView.postDelayed(new Runnable() {
@Override
public void run() {
listView.setSelection(listView.getCount());
}
}, 100);
但运行不正常在我的情况。
but is not working correctly in my case.
有谁知道为什么,可能会发生?有没有一种方法,它总是滚动的ListView结束?
Does anyone know why it may occur? Is there a way, which ALWAYS scroll ListView to end?
谢谢你的帮助是非常AP preciated!
Thanks, your help is much appreciated!
推荐答案
您可以尝试在设置后选择到您的列表中添加这行code:
You can try to add this line of code after you set selection to your list:
listView.smoothScrollToPosition(listView.getCount());
致使code应该是这样的:
Resulting code should look like this:
listView.postDelayed(new Runnable() {
@Override
public void run() {
listView.setSelection(listView.getCount());
listView.smoothScrollToPosition(listView.getCount());
}
}, 100);
这篇关于ListView控件不滚动到年底,键盘使用时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!