本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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()));
}
示例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);
}
}
});
}