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


Java RecyclerView.setOnTouchListener方法代碼示例

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


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

示例1: initView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initView(Context context) {
    mContext = context;
    View view = LayoutInflater.from(context).inflate(com.wuxiaolong.pullloadmorerecyclerview.R.layout.pull_loadmore_layout, null);
    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(com.wuxiaolong.pullloadmorerecyclerview.R.id.swipeRefreshLayout);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_green_dark, android.R.color.holo_blue_dark, android.R.color.holo_orange_dark);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayoutOnRefresh(this));

    mRecyclerView = (RecyclerView) view.findViewById(com.wuxiaolong.pullloadmorerecyclerview.R.id.recycler_view);
    mRecyclerView.setVerticalScrollBarEnabled(true);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addOnScrollListener(new RecyclerViewOnScroll(this));

    mRecyclerView.setOnTouchListener(new onTouchRecyclerView());

    mFooterView = view.findViewById(R.id.footerView);

    loadMoreLayout = (LinearLayout) view.findViewById(R.id.loadMoreLayout);
    loadMoreText = (TextView) view.findViewById(R.id.loadMoreText);

    mFooterView.setVisibility(View.GONE);

    this.addView(view);

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:PullLoadMoreRecyclerView.java

示例2: initView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initView(Context context) {
    mContext = context;
    View view = LayoutInflater.from(context).inflate(com.wuxiaolong.pullloadmorerecyclerview.R.layout.pull_loadmore_layout, null);
    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(com.wuxiaolong.pullloadmorerecyclerview.R.id.swipeRefreshLayout);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_green_dark, android.R.color.holo_blue_dark, android.R.color.holo_orange_dark);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayoutOnRefresh(this));

    mRecyclerView = (RecyclerView) view.findViewById(com.wuxiaolong.pullloadmorerecyclerview.R.id.recycler_view);
    mRecyclerView.setVerticalScrollBarEnabled(true);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());


    mRecyclerView.setOnTouchListener(new onTouchRecyclerView());

    mFooterView = view.findViewById(R.id.footerView);

    loadMoreLayout = (LinearLayout) view.findViewById(R.id.loadMoreLayout);
    loadMoreText = (TextView) view.findViewById(R.id.loadMoreText);
    mprogressBar = (ProgressBar)view.findViewById(R.id.loadMoreProgressBar) ;
    mFooterView.setVisibility(View.GONE);

    this.addView(view);

}
 
開發者ID:dufangyu1990,項目名稱:JKApp,代碼行數:27,代碼來源:PullLoadMoreRecyclerView.java

示例3: initView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initView(Context context) {
    mContext = context;
    View view = LayoutInflater.from(context).inflate(R.layout.pull_loadmore_layout, null);
    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_green_dark, android.R.color.holo_blue_dark, android.R.color.holo_orange_dark);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayoutOnRefresh(this));

    mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
    mRecyclerView.setVerticalScrollBarEnabled(true);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addOnScrollListener(new RecyclerViewOnScroll(this));

    mRecyclerView.setOnTouchListener(new onTouchRecyclerView());

    mFooterView = view.findViewById(R.id.footerView);

    loadMoreLayout = (LinearLayout) view.findViewById(R.id.loadMoreLayout);
    loadMoreText = (TextView) view.findViewById(R.id.loadMoreText);

    mFooterView.setVisibility(View.GONE);

    this.addView(view);

}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:27,代碼來源:PullLoadMoreRecyclerView.java

示例4: initRecyclerView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initRecyclerView(View view) {
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.content_list);
    recyclerView.setOnTouchListener(new VerticalVPOnTouchListener((DummyViewPager) getArguments().getSerializable("viewpager")));//set the vertical scroll controller
    recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(new ContentAdapter(getPosition()));
}
 
開發者ID:chadguo,項目名稱:VerticalViewPager,代碼行數:8,代碼來源:ContentFragment.java

示例5: onAttachedToRecyclerView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onAttachedToRecyclerView(final RecyclerView recyclerView)
{
    mInnerAdapter.onAttachedToRecyclerView(recyclerView);

    final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager)
    {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup()
        {
            @Override
            public int getSpanSize(int position)
            {
                if (isShowLoadView(position))
                {
                    return gridLayoutManager.getSpanCount();
                }
                if (spanSizeLookup != null)
                {
                    return spanSizeLookup.getSpanSize(position);
                }
                return 1;
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }

    recyclerView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()){
                case MotionEvent.ACTION_DOWN:
                    lastY = event.getRawY();
                    break;
                case MotionEvent.ACTION_MOVE:
                    isPullUp = event.getRawY() < lastY ;
                    break;
            }
            lastY  = event.getRawY();
            return false;
        }
    });

    recyclerView.addOnScrollListener(new OnRcvScrollListener(){
        @Override
        protected void onLoadMore() {
            super.onLoadMore();
            if(isEnableLoad() && isPullUp && !mRefreshing){
                isLoadingMore = true;
                mOnLoadMoreListener.onLoad();
            }
        }

        @Override
        protected void showLoadView() {
            super.showLoadView();
            if(isEnableLoad() && isPullUp && !mRefreshing) {
                mLoadView.setLoadViewType(BaseLoadView.TYPE_LOAD_MORE);
            }
        }
    });

}
 
開發者ID:evansherry,項目名稱:PullRefreshLoadMore,代碼行數:67,代碼來源:LoadMorePresenter.java


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