setNotifyOnChange(true) not working

我怕爱的太早我们不能终老 提交于 2019-12-11 15:07:02

问题


I have added below codes in onResume() method in my android activity.

    username.addTextChangedListener(this);
    usernames_adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_dropdown_item_1line,
            users.getUserList());
    username.setAdapter(usernames_adapter);
    usernames_adapter.setNotifyOnChange(true);

I'm inserting data into database using sql script. i need to show inserted data on username (username is a AutoCompleteTextView)just after inserting. so i used usernames_adapter.setNotifyOnChange(true);. but it is not working. i have to Force Stop my application to show inserted data on AutoCompleteTextView.

How could i solve this ?


回答1:


Change

usernames_adapter.setNotifyOnChange(true);

TO

usernames_adapter.notifyDataSetChanged();

this method work only when you delete, update and insert item.



来源:https://stackoverflow.com/questions/14846752/setnotifyonchangetrue-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!