Как я могу показать данные просмотра корзины из ListView
до следующего намерения по идентификатору в представлении карты. Это мой код, пожалуйста, проверьте и покажите результат
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.example.tanuj.recycleview.Product;
import com.example.tanuj.recycleview.R;
import java.util.List;
public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ProductViewHolder> {
private TextView textViewTitle,textViewShortDesc,textViewRating,textViewPrice;
private Context mCtx;
private List<Product> productList;
public ProductAdapter(Context mCtx, List<Product> productList) {
this.mCtx = mCtx;
this.productList = productList;
}
@Override
public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(mCtx);
View view = inflater.inflate(R.layout.product_list, null);
return new ProductViewHolder(view);
}
@Override
public void onBindViewHolder(ProductViewHolder holder, int position) {
Product product = productList.get(position);
Glide.with(mCtx)
.asBitmap()
.load(product.getImage())
.into(holder.imageView);
holder.textViewTitle.setText(product.getTitle());
holder.textViewShortDesc.setText(product.getShortdesc());
holder.textViewRating.setText(String.valueOf(product.getRating()));
holder.textViewPrice.setText(String.valueOf(product.getPrice()));
holder.textViewTitle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String data = "{}";
Intent intent = new Intent(mCtx,GalleryActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mCtx.startActivity(intent);
}
});
//Set on click on description
holder.textViewShortDesc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mCtx,"You are click On Description : " +textViewShortDesc,Toast.LENGTH_SHORT).show();
}
});
//Set on click on price
holder.textViewPrice.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mCtx,"You are click On Price",Toast.LENGTH_SHORT).show();
}
});
holder.textViewRating.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(mCtx,"You are click on rating",Toast.LENGTH_SHORT).show();
}
});
}
@Override
public int getItemCount() {
return productList.size();
}
class ProductViewHolder extends RecyclerView.ViewHolder {
TextView textViewTitle, textViewShortDesc, textViewRating, textViewPrice;
ImageView imageView;
public ProductViewHolder(View itemView) {
super(itemView);
textViewTitle = itemView.findViewById(R.id.textViewTitle);
textViewShortDesc = itemView.findViewById(R.id.textViewShortDesc);
textViewRating = itemView.findViewById(R.id.textViewRating);
textViewPrice = itemView.findViewById(R.id.textViewPrice);
imageView = itemView.findViewById(R.id.imageView);
}
}
}