當前位置: 首頁>>代碼示例>>Java>>正文


Java RecyclerView.setOnScrollListener方法代碼示例

本文整理匯總了Java中android.support.v7.widget.RecyclerView.setOnScrollListener方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.setOnScrollListener方法的具體用法?Java RecyclerView.setOnScrollListener怎麽用?Java RecyclerView.setOnScrollListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.RecyclerView的用法示例。


在下文中一共展示了RecyclerView.setOnScrollListener方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setParallaxHeader

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * Set the view as header.
 *
 * @param header The inflated header
 * @param view   The RecyclerView to set scroll listeners
 */
public void setParallaxHeader(View header, final RecyclerView view) {
    mRecyclerView = view;
    mHeader = new CustomRelativeWrapper(header.getContext(), mShouldClipView);
    mHeader.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mHeader.addView(header, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    view.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (mHeader != null) {
                translateHeader(mRecyclerView.getLayoutManager().getChildAt(0) == mHeader ?
                        mRecyclerView.computeVerticalScrollOffset() : mHeader.getHeight());

            }
        }
    });
}
 
開發者ID:guzhigang001,項目名稱:Bailan,代碼行數:24,代碼來源:ParallaxRecyclerAdapter.java

示例2: onCreateView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    RecyclerView view = new RecyclerView(getActivity());
    view.setLayoutManager(new LinearLayoutManager(getActivity(),
            LinearLayoutManager.VERTICAL, false));
    view.setAdapter(mAdapter);
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(view.getContext(),
            LinearLayoutManager.VERTICAL);
    view.addItemDecoration(dividerItemDecoration);
    view.setOnScrollListener(new OnLoadMoreListener() {
        @Override
        public void onLoadMore() {
            loadPage();
        }
    });
    return view;
}
 
開發者ID:Trumeet,項目名稱:MiPushFramework,代碼行數:19,代碼來源:EventFragment.java

示例3: bindView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void bindView(@NonNull RecyclerView view) {
    super.bindView(view);

    mSwipeItemTouchListener = new SwipeItemTouchListener(view.getContext(), mGroupBasicAdapter, getContentView());
    if (mSwipeCardActionEdge != -1) {
        mSwipeItemTouchListener.setActionEdge(mSwipeCardActionEdge);
    }

    view.addOnItemTouchListener(mSwipeItemTouchListener);
    view.setOnScrollListener(new RecyclerView.OnScrollListener(){
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (recyclerView != null) {
                scrolledY += dy;
            }
        }
    });
}
 
開發者ID:alibaba,項目名稱:Tangram-Android,代碼行數:24,代碼來源:TangramEngine.java

示例4: initRecyclerView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initRecyclerView(){

        RecyclerView recyclerView = (RecyclerView) searchActivity.findViewById(R.id.recycler);
        recyclerView.setAdapter(classAdapter);

        userClasses = getFormatedClasses(userClasses);
        searchActivity.classAdapter = new ClassAdapter(userClasses, getApplicationContext(), recyclerView);
        classAdapter = searchActivity.classAdapter;
        classAdapter.setOnItemClickListener(callJoinClass());
        recyclerView.setAdapter(classAdapter);

        RecyclerView.LayoutManager layout = new LinearLayoutManager(application,
                LinearLayoutManager.VERTICAL, false);
        recyclerView.setLayoutManager(layout);

        recyclerView.setOnScrollListener(new HidingScrollListener() {
            @Override
            public void onHide() {
                searchActivity.hideViews();
            }
            @Override
            public void onShow() {
                searchActivity.showViews();
            }
        });
    }
 
開發者ID:fga-gpp-mds,項目名稱:2017.1-Trezentos,代碼行數:27,代碼來源:ServerOperationSearchActivity.java

示例5: initViews

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void initViews() {
    setContentView(R.layout.activity_share);
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);

    // Layout Managers:
    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    recyclerView.setItemAnimator(new DefaultItemAnimator());

    // Adapter:
    String[] adapterData = new String[]{"Alabama", "Alaska", "Arizona", "Arkansas", "California",
            "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho",
            "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland",
            "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana",
            "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York",
            "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania",
            "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah",
            "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"};
    mDataSet = new ArrayList<String>(Arrays.asList(adapterData));
    mAdapter = new RecyclerViewAdapter(this, recyclerView, mDataSet);
    ((RecyclerViewAdapter) mAdapter).setMode(Attributes.Mode.Single);
    recyclerView.setAdapter(mAdapter);

    /* Listeners */
    recyclerView.setOnScrollListener(onScrollListener);

    try {
        new ItemTouchBuilder()
                .setList(mDataSet)
                .setAdapter(mAdapter)
                .setSwappable(false)
                .create(recyclerView)
                .attachToRecyclerView(recyclerView);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:ymqq,項目名稱:CommonFramework,代碼行數:39,代碼來源:ShareActivity.java

示例6: onCreate

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_webtoon_view);

        // get the intent information.
        inIntent = getIntent();
        webtoonHashID = inIntent.getStringExtra("webtoonHashID");
        chapterHashID = inIntent.getStringExtra("chapterHashID");
        chapterTitle = inIntent.getStringExtra("chapterTitle");

        setTitle(chapterTitle);

        // Link the RecyclerView, and generate the dbManager.
        webtoonViewRecyclerView = (RecyclerView)findViewById(R.id.webtoon_view_recycler_view);
        dbManager = new DBManager(this);

        // no need for asking the permission as WebtoonListActivity checked it.
        initializeLists();

        // setting the recyclerView.
        WebtoonViewRecyclerAdapter adapter = new WebtoonViewRecyclerAdapter(this, webtoonImages);
        webtoonViewRecyclerView.setAdapter(adapter);
        webtoonViewRecyclerView.setLayoutManager(new LinearLayoutManager(this));

        // Make action bar hidden when scrolled.
//        webtoonViewRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
//            @Override
//            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
//                super.onScrolled(recyclerView, dx, dy);
//                if (dy > 40) {
//                    isScrolledDown = true;
//                } else if (dy < -5) {
//                    isScrolledDown = false;
//                }
//            }
//
//            @Override
//            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
//                super.onScrollStateChanged(recyclerView, newState);
//                if (isScrolledDown) {
//                    getSupportActionBar().hide();
//                } else {
//                    getSupportActionBar().show();
//                }
//            }
//        });

        webtoonViewRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                if (isAtBottom(recyclerView)) {
                    Intent intent = new Intent(getApplicationContext(), ARToonActivity.class);
                    getApplicationContext().startActivity(intent);
                }
            }
        });
    }
 
開發者ID:Jamjomjara,項目名稱:snu-artoon,代碼行數:59,代碼來源:WebtoonViewActivity.java

示例7: onViewCreated

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // 實例化發布問題按鈕
    btnPublish = (FloatingActionButton)view.findViewById(R.id.button_publish);
    btnPublish.setOnClickListener(this);
    // 實例化刷新布局
    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_light,
            android.R.color.holo_red_light,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light);
    TypedValue typed_value = new TypedValue();
    getActivity().getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, typed_value, true);
    mSwipeRefreshLayout.setProgressViewOffset(false, 0, getResources().getDimensionPixelSize(typed_value.resourceId));
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            // 下拉刷新
            page = 1;
            new LoadQuestionList().execute();
        }
    });
    mSwipeRefreshLayout.setRefreshing(true);
    // 實例化RecyclerView
    mRecyclerView = (RecyclerView) view.findViewById(R.id.question_list);
    final LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new QuestionViewAdapter(getActivity(), mList);
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            int visibleItemCount = mLayoutManager.getChildCount();
            int totalItemCount = mLayoutManager.getItemCount();
            int pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();
            if (loading) {
                if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
                    // 達到底部加載更多
                    loading = false;
                    mSwipeRefreshLayout.setRefreshing(true);
                    new LoadQuestionList().execute();
                }
            }
            // 自動隱藏發布按鈕
            if (Math.abs(dy) > ScrollOffset)
                if (dy > 0)
                    btnPublish.hide(true);
                else
                    btnPublish.show(true);
        }
    });
    // 開始載入問題操作
    new LoadQuestionList().execute();
}
 
開發者ID:moe2studio,項目名稱:PangciACG,代碼行數:57,代碼來源:ExploreFragment.java


注:本文中的android.support.v7.widget.RecyclerView.setOnScrollListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。