我能够检测到个别回收者查看项目的位置,并能够点击它来烘烤它.现在我不想继续进行新的活动,并显示点击项目的详细信息,我该怎么做?
说,我正在显示联系人姓名列表和onclick我不想打开一个新的活动节目联系人的详细信息…
至少,如何在点击该联系人项目时再次举报联系人姓名,点击时可用的当前变量如何?
我打算捆绑这些变量并发送它们并在那里显示.
说,我正在显示联系人姓名列表和onclick我不想打开一个新的活动节目联系人的详细信息…
至少,如何在点击该联系人项目时再次举报联系人姓名,点击时可用的当前变量如何?
我打算捆绑这些变量并发送它们并在那里显示.
我知道我必须在这里实施
public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener { private OnItemClickListener mListener; public interface OnItemClickListener { public void onItemClick(View view,int position){ //i know i have to implement here } }
解决方法
我有同样的问题,直到我这样做.
创建了一个客户RecyclerListener:
public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener { private OnItemClickListener mListener; public interface OnItemClickListener { public void onItemClick(View view,int position); } GestureDetector mGestureDetector; public RecyclerItemClickListener(Context context,OnItemClickListener listener) { mListener = listener; mGestureDetector = new GestureDetector(context,new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }); } @Override public boolean onInterceptTouchEvent(RecyclerView view,MotionEvent e) { View childView = view.findChildViewUnder(e.getX(),e.getY()); if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) { mListener.onItemClick(childView,view.getChildAdapterPosition(childView)); } return false; } @Override public void onTouchEvent(RecyclerView view,MotionEvent motionEvent) { } @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { } }
然后在使用recyclerView的活动中:
private void registerCallClickBack() { recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getActivity().getApplicationContext(),new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view,int position) { Intent intent = new Intent(this,DetailActivity.class); intent.putExtra("contact_name",customList.get(position).getName()); intent.putExtra("contact_image",customList.get(position).getImage()); intent.putExtra("contact_tel",customList.get(position).getMobile()); intent.putExtra("contact_email",customList.get(position).getEmail()); startActivity(intent); } })); }
其中customList是我的联系人ArrayList.
希望能帮助到你