在适配器中设置项的点击事件即可,如需跳转Activity,则需要intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
@Override
publicViewHolder onCreateViewHolder(ViewGroup parent,final intviewType) {
itemView= LayoutInflater.from(parent.getContext())
.inflate(R.layout.recyclerview_item,parent,false);
BBX_Adapter.ViewHolder viewHolder =newBBX_Adapter.ViewHolder(itemView);
returnviewHolder;
}
@Override
public voidonBindViewHolder(ViewHolder holder,final intposition) {
BBX bbx=list.get(position);
itemView.setOnClickListener(newView.OnClickListener() {
@Override
public voidonClick(View view) {
switch(position){
case6:
Intent intent=newIntent(MyApplication.getContext(), family_Activity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
MyApplication.getContext().startActivity(intent);
break;
case0:
Toast.makeText(MyApplication.getContext(),"nnnn", Toast.LENGTH_SHORT).show();
break;
}
}
});
holder.imageView.setImageDrawable(getBBXIcon(bbx.getIcon()));
holder.textView.setText(bbx.getUsername());
}