gpt4 book ai didi

java - Listview,滚动到底部,EditText View 的奇怪行为

转载 作者:行者123 更新时间:2023-11-30 01:25:37 33 4
gpt4 key购买 nike

我尝试将 ListView 滚动到最底部,它是这样工作的:

listview.setSelection(listview.getCount()-1);

(谷歌真可耻,基本的东西 scrollToBottom 方法,我们不得不找到其他方法来实现它..)

但这不起作用.. 在使用它之前,您键入一些文本.. 到 EditText View 中。有趣的?一点也不。

Add element to listview -> scrollToBottom -> you are at the very bottom - works
Add element to listview -> type something in EditView -> scrollToBottom - not works
Add element to listview -> type something in EditView -> click anywhere in screen -> scrollToBottom - works!

正如我们所见,问题很奇怪,我正在尝试 [anyView].performClick(); 但没有成功..

知道为什么在 EditText 中输入让我想到负责 listview 的 Android 开发团队是如此蹩脚吗?以及我们如何找到解决此错误的方法。

感谢您的帮助! :)

部分代码:

<ListView
android:id="@+id/nativeLog"
android:focusable="false"
android:focusableInTouchMode="false"
android:transcriptMode="normal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="0dp"
android:paddingBottom="10dp"
android:clipToPadding="false"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:cacheColorHint="#00000000"
android:background="@drawable/gray_bg"
android:listSelector="@color/transparent"
android:divider="@null"
android:dividerHeight="0dp"/>

[...]

<EditText
android:id="@+id/boxInterfaceEditbox"
android:scrollHorizontally="false"
android:inputType="textCapSentences|textLongMessage|textMultiLine|textNoSuggestions"
android:singleLine="false"
android:imeOptions="actionSend"
android:layout_width ="0dp"
android:layout_weight="1"
android:layout_height ="wrap_content"
android:layout_marginLeft="5.5dp"
android:layout_marginRight="5.5dp"
android:paddingTop="8.2dp"
android:paddingBottom="8.2dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:minHeight="@dimen/nav_interface_btn_size"
android:maxHeight="90dp"
android:textColor="#bbb"
android:textSize="15.25dp"
android:gravity="top"
android:background="@drawable/nav_boxtextarea"/>

和java

scrollToBottomRunnable = new Runnable() {
@Override
public void run() {
log.setSelection(log.getCount() -1);
}
};

最佳答案

因为我们尝试了评论中的所有内容,至少我们发现应该在将项目添加到 ListView 之后以及在切换 listview-footer-child 的可见性之后调用 notifyDatasetChanged()

关于java - Listview,滚动到底部,EditText View 的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36457758/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com