我已经拍了拍列表视图后,列表视图只更新 [英] list view only updates after i have tapped on the list view

查看:173
本文介绍了我已经拍了拍列表视图后,列表视图只更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的列表视图只有当我拖动或拍了拍它,直到它与新的价值没有得到更新来更新。

 公共无效的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆