Example usage for android.widget ScrollView fullScroll

List of usage examples for android.widget ScrollView fullScroll

Introduction

In this page you can find the example usage for android.widget ScrollView fullScroll.

Prototype

public boolean fullScroll(int direction) 

Source Link

Document

Handles scrolling in response to a "home/end" shortcut press.

Usage

From source file:com.google.reviewit.ReviewChangesFragment.java

private void init() {
    SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) v(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setColorSchemeColors(widgetUtil.color(R.color.progressBar));
    swipeRefreshLayout.setRefreshing(true);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override//from w ww  . j  ava 2  s .co m
        public void onRefresh() {
            getApp().getQueryHandler().reset();
            loadAndDisplay(true);
        }
    });

    v(R.id.reloadButton).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            reloadQuery();
        }
    });

    final View nextPageProgress = v(R.id.nextPageProgress);
    final ScrollView scrollView = (ScrollView) v(R.id.scrollView);
    scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
        @Override
        public void onScrollChanged() {
            if (isAdded() && getApp().getQueryHandler().hasNext()
                    && nextPageProgress.getVisibility() == View.GONE) {
                View lastChild = scrollView.getChildAt(scrollView.getChildCount() - 1);
                if ((lastChild.getBottom() - (scrollView.getHeight() + scrollView.getScrollY())) == 0) {
                    setVisible(nextPageProgress);
                    scrollView.post(new Runnable() {
                        @Override
                        public void run() {
                            scrollView.fullScroll(View.FOCUS_DOWN);
                            loadAndDisplay();
                        }
                    });
                }
            }
        }
    });
}

From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java

protected void expandDetails() {
    // Memberdetails
    for (int id : new int[] { R.id.member_details_title, R.id.members }) {
        findViewById(id).setVisibility(View.VISIBLE);
    }// w  ww . ja  va2s .c o  m

    findViewById(R.id.member_summary).setVisibility(View.GONE);

    final ScrollView msgScrollView = (ScrollView) findViewById(R.id.message_scroll_view);
    msgScrollView.post(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            msgScrollView.fullScroll(ScrollView.FOCUS_DOWN);
        }
    });
}