0
私はいくつかのCardViewアイテムを持っています。私はそれをクリックすると、別のアクティビティを開きたいと思います。 これは私のCardViewアダプタクラスの一部クリック時のcardviewが間違った結果を返す
@Override
public int getItemCount() {
return productGroups.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
private TextView txtGroupName;
public ViewHolder(final View view) {
super(view);
txtGroupName = (TextView)view.findViewById(R.id.txtNameOfGroup);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (getLayoutPosition()){
case 0: Intent intent = new Intent(view.getContext(),MyProductsActivity.class);
view.getContext().startActivity(intent);
case 1: Intent intent1 = new Intent(view.getContext(), VegetablesActivity.class);
view.getContext().startActivity(intent1);
}
}
});
}
}
である私は、最初の項目をクリックしてください(MyProductsActivity.class
を開きたい)が、VegetablesActivity.class
を開き、私は自分の携帯電話のボタンを背面クリックしたときにのみあなたがするのを忘れMyProductsActivity.class
ありがとうございます –