Why android: transcriptMode = "normal" is not working properly?

I dealt a lot with the question that I had. What happens, every time an item is added to my list (adapter), I expect it to scroll automatically if I am in the last item (which it will do to some extent); HOWEVER, if 3 or more points are added immediately, it will not automatically scroll.

Here is the XML of this list:

    <ListView android:id="@android:id/list"
    android:layout_width="fill_parent" 
    android:layout_height="0dip"
    android:layout_weight="1"
    android:transcriptMode="normal"/>

I tried a workaround using the snippet I found here .

My code is as follows:

public void addChat(final String text, final String username) {
    this.runOnUiThread(new Runnable() {
        public void run() {
            globals.chatAdapter.add(DateFormat.format("hh:mmaa", Calendar.getInstance()).toString(), username, text);

            globals.chatAdapter.notifyDataSetChanged();

            int lastP = getListView().getLastVisiblePosition();
            int count = globals.chatAdapter.getCount() - 1;

            if (lastP == globals.chatAdapter.oldP || lastP == -1) {
                getListView().setSelection(count);
            }

            globals.chatAdapter.oldP = count;
        }
    });
}

, getListView(). getLastVisiblePosition() , setSelection() , , .

?

+5
3

... , .

-

    this.getListView().setOnScrollListener(new OnScrollListener() {
        public void onScroll(AbsListView view, int first, int visible, int total) {
            if (visible == 0 || visible < total && (first + visible == total) || (getListView().getTranscriptMode() == 2) && (first + visible == total)) {
                if (getListView().getTranscriptMode() != 2)
                    getListView().setTranscriptMode(2);
            } else {
                if (getListView().getTranscriptMode() != 0)
                    getListView().setTranscriptMode(0);
            }
        }

        public void onScrollStateChanged(AbsListView view, int scrollState) {}
    });

6/6/11:

, ( , xScroll xml). , :

        getListView().setOnScrollListener(new OnScrollListener() {
            public void onScroll(AbsListView view, int first, int visible, int total) {
                    if (visible == 0 || visible == total || (first + visible == total) {
                        if (getListView().getTranscriptMode() != AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL)
                            getListView().setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
                    } else {
                        if (getListView().getTranscriptMode() != AbsListView.TRANSCRIPT_MODE_DISABLED)
                            getListView().setTranscriptMode(AbsListView.TRANSCRIPT_MODE_DISABLED);
                    }
            }

            public void onScrollStateChanged(AbsListView view, int scrollState) {}
        });
+9

.

lv.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

-, . TRANSCRIPT_MODE_ALWAYS_SCROLL .

-2

XML,

android:transcriptMode="alwaysScroll"
-3

All Articles