java - Android ListView not refreshing until scrolled -


i have faced strange listview.

i have fragment message listener inside, populates listview data. so, when initialize fragment activity's oncreate, listview refreshing on new messages (i'm using notifydatasetchanged method). if replace/add fragment onclicklistener inside activity, listview stops refreshing until drag manually. problem occurs on api 16 level, on api 25 it's working great in both cases.

listview initialization:

messageslistview =  (listview)rootview.findviewbyid(r.id.messageslistview); messages_adapter = new messageadapter(getactivity(),  messageslistview); //set autoscroll of listview when new message arrives messageslistview.settranscriptmode(     listview.transcript_mode_always_scroll); messageslistview.setstackfrombottom(true); messageslistview.setadapter(messages_adapter); 

refreshing method: (inside adapter class)

public void add(mymessage object) {     //arraylist<mymessage> messages     messages.add(object);     notifydatasetchanged();     lv.smoothscrollbyoffset(messages.size()-1); } 

and call list refresh inside

activity.runonuithread() 

i have tried requestlayout() method, , nothing happens.

if inside oncreate method place handler().postdelayed 1000ms replace/add fragment, listview doesn't refreshes data also.

have found answer.

it custom library taken focus out of current layout, deleted piece of code, , working expected. still strange, why working on api 25, api 16.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -