How to set ListView Scroll position to bottom in android?

android, android-listview

Solution

try this. the below code is working fine for me.

give time delay 500 for load listview then call setselection method.

commentslistview.postDelayed(new Runnable() {
    @Override
    public void run() {
        commentslistview.setSelection(commentsarraylist.size());
    }
}, 500);

Problem

I know this question is asked several times before but my situation is bit different from other questions. I have a listview and initially i want to set the scroll position to the bottom of the list. I have try 2 ways. 1st one ``` mCommentListView.setSelection(mAdaptor.getCount()-1); ``` 2nd one ``` mCommentListView.post(new Runnable() { @Override public void run() { mCommentListView.setSelection(mAdaptor.getCount()-1); } }); ``` So my problem is both of above code working properly with the emulator but it is not working with the real device. What have i missed?

Original source

Related problems