0
도와주세요. RecyclerView.Adapter<CustomAdapter.ViewHolder>
(첫 번째 의도)에서 내 세부 제품 두 번째까지 이미지, 텍스트 및 세부 제품을 표시하고 싶습니다. 의도와 의도. 하지만 Second Intent에서 선언 할 때 First Intent의 변수 abc에 액세스 할 수 없습니다.다른 활동에 선언 할 때 RecyclerView.Adapter <CustomAdapter.ViewHolder>의 변수 인 텐트에 액세스 할 수 없음
제발 도와주세요.
이 RecyclerView.Adapter<CustomAdapter.ViewHolder>
또는 첫 번째 의도
public class ViewHolder extends RecyclerView.ViewHolder{
private ImageView image;
private TextView text;
private TextView nama;
private TextView harga;
public ViewHolder(final View itemView) {
super(itemView);
image = (ImageView) itemView.findViewById(R.id.image);
text = (TextView) itemView.findViewById(R.id.text);
nama= (TextView) itemView.findViewById(R.id.nama);
harga = (TextView) itemView.findViewById(R.id.harga);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent abc = new Intent(v.getContext(), DetailProduct.class);
abc.putExtra("abb", my_data.get(getAdapterPosition()).getDetail());
v.getContext().startActivity(abc);
}
});
}
}
입니다 그리고 이것은 내 상세 제품 또는 두 번째 의도
입니다@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail_product);
TextView resulttext = (TextView) findViewById(R.id.hasiltext);
String text = abc.getStringExtra("abb"); // i cannot acces variable abc in detailproduct
resulttext.setText(text);
}
때문에 오류 메시지가 무엇을 도망? Stacktrace/컴파일러 출력? – observer
안녕하세요, StackOverflow에 오신 것을 환영합니다. 게시물을 편집하여 위의 설명에서 요청한 @observer 정보를 추가하십시오. 그렇게하면 우리는 당신을 도울 수있는 방법을 찾을 수 있습니다 :). [질문하는 방법에 대한이 기사] (https://stackoverflow.com/help/how-to-ask) –
문제가 해결되었지만 RecyclerView.Adapter의 이미지를 세부 제품에 표시 할 때 문제가 발견되었습니다. 오류 : – Alan