我已经拍了拍列表视图后,列表视图只更新 [英] list view only updates after i have tapped on the list view
问题描述
我的列表视图只有当我拖动或拍了拍它,直到它与新的价值没有得到更新来更新。
公共无效的AddItem(最终字符串名称,最后弦乐一塌糊涂){
runOnUiThread(新的Runnable(){ @覆盖
公共无效的run(){
消息v =新消息();
v.setName(名);
v.setmessage(混乱);
PersonList.add(五);
mConversationArrayAdapter.notifyDataSetChanged();
mConversationView.invalidateViews();
mConversationView.setSelection(mConversationArrayAdapter.getCount() - 1); }
});}
< ListView控件
机器人:ID =@ + ID /列表
机器人:layout_width =FILL_PARENT
机器人:layout_height =0dp
机器人:layout_weight =1
机器人:背景=@空
机器人:分=@空
机器人:transcriptMode =alwaysScroll
机器人:stackFromBottom =真正的>
< /&的ListView GT;
由于transcriptMode一套它。
安卓transcriptMode
设置列表中的转录模式。在谈话模式,列表滚动至底部,使新项目可见加时。
删除transcriptMode或将其设置为禁用为你的问题的解决方案。
请参考,<一个href=\"http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:transcriptMode\" rel=\"nofollow\">http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:transcriptMode
My listview only update if I drag it up or tapped it till its not getting update with new values.
public void additem(final String name,final String mess) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Messages v=new Messages();
v.setName(name);
v.setmessage(mess);
PersonList.add(v);
mConversationArrayAdapter.notifyDataSetChanged();
mConversationView.invalidateViews();
mConversationView.setSelection(mConversationArrayAdapter.getCount() - 1);
}
});
}
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@null"
android:divider="@null"
android:transcriptMode="alwaysScroll"
android:stackFromBottom="true">
</ListView>
Its because of the transcriptMode set.
android:transcriptMode
Sets the transcript mode for the list. In transcript mode, the list scrolls to the bottom to make new items visible when they are added.
Remove transcriptMode or set it to disabled as a solution for your problem.
Please Refere : http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:transcriptMode
这篇关于我已经拍了拍列表视图后,列表视图只更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!