本文整理匯總了Java中android.support.v7.widget.RecyclerView.addOnItemTouchListener方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.addOnItemTouchListener方法的具體用法?Java RecyclerView.addOnItemTouchListener怎麽用?Java RecyclerView.addOnItemTouchListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.addOnItemTouchListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPref pref= new SharedPref(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_event);
Toolbar toolbar= (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
progressBar= (ProgressBar) findViewById(R.id.progress);
adapter=new ClubEventAdapter(this);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new GridLayoutManager(this,2));
recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Intent i=new Intent(EventActivity.this,ClubActivity.class);
i.putExtra(CLUB_ID,list.get(position).getId());
startActivity(i);
}
}));
showData();
}
示例2: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz_category);
progressBar = (ProgressBar) findViewById(R.id.category_progress);
toolbar = (Toolbar) findViewById(R.id.category_toolbar);
recyclerView = (RecyclerView) findViewById(R.id.category_recycler);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
progressBar.setVisibility(View.VISIBLE);
layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Intent i=new Intent(QuizCategoryActivity.this,QuizSubCategoryActivity.class);
i.putExtra("Category_Name",categories.get(position).getName());
startActivity(i);
}
}));
getCategories();
}
示例3: attachToRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void attachToRecyclerView(RecyclerView recyclerView)
{
if (this.recyclerView == recyclerView)
{
return;
}
if (this.recyclerView != null)
{
destroyCallbacks();
}
this.recyclerView = recyclerView;
if (recyclerView == null)
{
return;
}
onItemTouchListener = new TasksOnItemTouchListener(recyclerView.getContext());
itemDecoration = new TasksItemDecoration();
recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
recyclerView.addOnItemTouchListener(onItemTouchListener);
recyclerView.addItemDecoration(itemDecoration);
recyclerView.setAdapter(adapter);
final Context context = this.recyclerView.getContext();
final ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
scaledTouchSlop = viewConfiguration.getScaledTouchSlop();
DisplayMetrics metrics = new DisplayMetrics();
final WindowManager systemService = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
systemService.getDefaultDisplay().getMetrics(metrics);
logicalDensity = metrics.density;
adapter.setOnFirstItemUpdateListener(new OnFirstItemUpdateListener());
}
示例4: 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;
}
}
});
}
示例5: onCreateView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup,
Bundle savedInstanceState) {
RecyclerView recyclerView = new RecyclerView(getActivity());
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
mAdapter.bindToRecyclerView(recyclerView);
mAdapter.setEmptyView(R.layout.layout_empty);
recyclerView.addOnItemTouchListener(new OnItemClickListener() {
@Override
public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
MultiItemEntity entity = mAdapter.getItem(position);
switch (entity.getItemType()) {
case RuleItem.TYPE_RULE :
RuleItem item = (RuleItem) entity;
RuleDetailFragment.newInstance(item)
.show(getChildFragmentManager(), "Detail");
break;
}
}
});
return recyclerView;
}
示例6: initviews
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initviews(View view) {
mlist = new ArrayList<>();
refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_news);
recyclerView = (RecyclerView) view.findViewById(R.id.rv_buyer);
refreshLayout.setColorSchemeResources(R.color.blue_500, R.color.purple_500, R.color.green_500);
refreshLayout.setOnRefreshListener(this);
linearLayoutManager = new LinearLayoutManager(getActivity());
linearLayoutManager.setOrientation(OrientationHelper.VERTICAL);
madapter = new SellerRecyclerAdapter();
madapter.addData(mlist);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(madapter);
recyclerView.addOnScrollListener(new OnRecyclerScrollListener());
recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getActivity(), onItemClickListener));
}
示例7: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz_sub_category);
Intent i1 = this.getIntent();
if(i1!=null)
{
categoryname = i1.getExtras().getString("Category_Name");
}
progressBar = (ProgressBar) findViewById(R.id.subcategory_progress);
toolbar = (Toolbar) findViewById(R.id.subcategory_toolbar);
recyclerView = (RecyclerView) findViewById(R.id.subcategory_recycler);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
progressBar.setVisibility(View.VISIBLE);
layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Intent i = new Intent(getApplicationContext(),QuizActivity.class);
i.putExtra("Category_Name",subcategories.get(position).getCategory());
i.putExtra("Topic_Name",subcategories.get(position).getName());
startActivity(i);
}
}));
getsubcategory();
}
示例8: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPref pref= new SharedPref(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_event);
Toolbar toolbar= (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
recyclerView=(RecyclerView)findViewById(R.id.recycler_view);
LinearLayoutManager manager=new LinearLayoutManager(BattleDayActivity.this);
recyclerView.setLayoutManager(manager);
adapter=new BattleDayAdapter(BattleDayActivity.this);
recyclerView.setAdapter(adapter);
bar=(ProgressBar)findViewById(R.id.progress);
recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Intent i=new Intent(BattleDayActivity.this,ClubActivity.class);
i.putExtra("name",list.get(position).getName());
i.putExtra("id",list.get(position).getId());
i.putExtra("battleday",true);
startActivity(i);
}
}));
bar.setVisibility(View.VISIBLE);
retrofit();
}
示例9: initRecycler
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initRecycler(RecyclerView productsRecycler) {
productsRecycler.setHasFixedSize(true);
productsRecycler.setAdapter(new ProductAdapter(mProducts));
productsRecycler.addItemDecoration(new ProductItemPaddingDecoration(this));
productsRecycler.addOnItemTouchListener(new OnItemSelectedListener(this) {
@Override
public void onItemSelected(RecyclerView.ViewHolder holder, int position) {
//彈窗
OrderDialogFragment.newInstance(mProducts.get(position)).show(getSupportFragmentManager(), null);
}
});
}
示例10: onAttachedToRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@CallSuper
@Override
protected void onAttachedToRecyclerView(@NonNull final RecyclerView recyclerView) {
final EnchancedGestureDetector.OnGestureListener onGestureListener = new DefaultGestureListener(recyclerView);
mGestureDetector = new EnchancedGestureDetector(recyclerView.getContext(), onGestureListener);
mGestureDetector.setLongpressEnabled(isLongPressEnabled());
recyclerView.addOnItemTouchListener(mOnItemTouchListener);
}
示例11: registerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* Register Recycler view for product list tracking. Please call {@link #unregisterView(RecyclerView)}
* after RecyclerView is hided
* @param view RecyclerView instance
* @param timeoutMilliseconds timeout that is used when list is scrolled. Position of product
* is tracked if list has this delay after scrolling or first show-up
* @param itemCallback - callback to provide information about product
*/
public void registerView(@NonNull RecyclerView view, @IntRange(from=0) final long timeoutMilliseconds, @NonNull final ProductListItemCallback itemCallback){
final RecyclerView.LayoutManager layoutManager = view.getLayoutManager();
//we not support others layout managers then LinearLayoutManager
if (!(layoutManager instanceof LinearLayoutManager)) {
WebtrekkLogging.log("Error: not LinearLayouManager isn't supported");
return;
}
mDelayHandler = new Handler();
mScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE){
initPendingList(recyclerView, timeoutMilliseconds, itemCallback);
}else{
clearPendingEvents();
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
//it equals zero on the first list start in that case start pending
if (dy == 0){
initPendingList(recyclerView, timeoutMilliseconds, itemCallback);
}
}
};
view.addOnScrollListener(mScrollListener);
mOnTouсhEventListener = new RecyclerItemClickListener(view.getContext(), view);
view.addOnItemTouchListener(mOnTouсhEventListener);
initPendingList(view, timeoutMilliseconds, itemCallback);
}
示例12: initRecycler
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initRecycler(RecyclerView productsRecycler) {
productsRecycler.setAdapter(new ProductAdapter(fakeProducts));
productsRecycler.addItemDecoration(new ProductItemPaddingDecoration(this));
productsRecycler.addOnItemTouchListener(new OnItemSelectedListener(this) {
@Override
public void onItemSelected(RecyclerView.ViewHolder holder, int position) {
OrderDialogFragment.newInstance(fakeProducts.get(position)).show(getSupportFragmentManager(), null);
}
});
}
示例13: initRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void initRecyclerView(final Activity mContext, RecyclerView mRecyclerViewDrawer, List<DrawerEntity> list) {
final BaseQuickAdapter mAdapterDrawer = new DrawerAdapter(mContext);
mRecyclerViewDrawer.setLayoutManager(new LinearLayoutManager(mContext));
mRecyclerViewDrawer.setAdapter(mAdapterDrawer);
mRecyclerViewDrawer.addOnItemTouchListener(new OnItemClickListener() {
@Override
public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
DrawerEntity entity = (DrawerEntity) mAdapterDrawer.getItem(position);
WebViewActivity.start(mContext, entity.url);
}
});
mAdapterDrawer.setNewData(list);
}
示例14: initRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void initRecyclerView(final Activity mContext, RecyclerView mRecyclerViewDrawer, List<DrawerEntity> list) {
final BaseQuickAdapter mAdapterDrawer = new DrawerAdapter(mContext);
mRecyclerViewDrawer.setLayoutManager(new LinearLayoutManager(mContext));
mRecyclerViewDrawer.setAdapter(mAdapterDrawer);
mRecyclerViewDrawer.addOnItemTouchListener(new OnItemClickListener() {
@Override
public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
DrawerEntity entity = (DrawerEntity) mAdapterDrawer.getItem(position);
WebViewActivity.start(mContext,entity.url);
}
});
mAdapterDrawer.setNewData(list);
}
示例15: initListView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void initListView(IMMessage anchor) {
listviewBk = (ImageView) rootView.findViewById(R.id.message_activity_background);
// RecyclerView
messageListView = (RecyclerView) rootView.findViewById(R.id.messageListView);
messageListView.setLayoutManager(new LinearLayoutManager(container.activity));
messageListView.requestDisallowInterceptTouchEvent(true);
messageListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState != RecyclerView.SCROLL_STATE_IDLE) {
container.proxy.shouldCollapseInputPanel();
}
}
});
messageListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
// adapter
items = new ArrayList<>();
adapter = new MsgAdapter(messageListView, items, container);
adapter.setFetchMoreView(new MsgListFetchLoadMoreView());
adapter.setLoadMoreView(new MsgListFetchLoadMoreView());
adapter.setEventListener(new MsgItemEventListener());
initFetchLoadListener(anchor);
messageListView.setAdapter(adapter);
messageListView.addOnItemTouchListener(listener);
}