ListView 修改页脚时跳转到顶部
我正在尝试创建一个简单的聊天布局。
我有一个带有transcriptMode =“alwaysScroll”和setStackFromBottom(true)的ListView。 ListView 有一个带有 EditText 和按钮的页脚(它是页脚,因为我希望它随列表滚动)。
每当用户在 EditText 中键入内容时,我都会使用 TextWatcher 更改按钮上的文本。
问题是,当使用物理键盘时,输入的每个字母都会将列表滚动到顶部,并阻止其他字母进入 EditText。 它与软键盘配合得很好...
我认为这可能与页脚更改调用适配器刷新有关,但似乎并非如此。
这是 Android 的错误还是我遗漏了什么?
谢谢。
编辑: 我忘记添加的另一件重要的事情很奇怪,当输入任何字母时滚动到顶部,但是当删除字符时它工作正常,相同的 afterTextChanged 被调用。
I'm trying to create a simple chat layout.
I have a ListView with transcriptMode="alwaysScroll" and setStackFromBottom(true).
The ListView has a footer with an EditText and a button (It's a footer because I want it to scroll with the list).
Whenever the user types in the EditText i change the text on the button, using a TextWatcher.
The problem is that when using a physical keyboard, every letter typed scrolls the list to the top, and prevents additional letters to get into the EditText.
It works fine with soft keyboard...
I've thought it might be related to the footer being changes calling the adapter to refresh, but it doesn't seem to be that.
Is this an Android bug or am I missing something?
Thanks.
EDIT:
Another important thing I forgot to add, and is very weird, when typing any letter is scrolls to top, but when deleting characters it works ok, the same afterTextChanged gets called.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,看起来我已经解决了这个问题,
afterTextChanged 强制在 ListView 中重新布局,导致它跳到顶部(应该跳到底部,因为我设置了 stackFromBottom)。
不管怎样,我已经将一些视图从wrap_content切换到其他替代方案,并将隐藏视图上的可见性“消失”切换为“不可见”,这样就不必在每个字母之后调用onMeasure并且它起作用了。
希望这对某人有帮助...
Well, looks like I've solved it,
The afterTextChanged forced a re-layout in the ListView causing it to jump to top (which should have been jump to bottom because I've set stackFromBottom).
Anyway, I've switched some views from wrap_content to other alternatives, and switched from using visibility 'gone' on hidden views to 'invisible' so that the onMeasure wouldn't have to be called after every letter and it worked.
Hope this helps someone...
看看这是否有帮助 通过这个网站
See whether this helps via this site