Lompat ke konten Lompat ke sidebar Lompat ke footer

Cara Menggunakan LayoutInflater Di Dalam Adapter onBindViewHolder

 Kode Yang Saya Pasangkan 

 

LayoutInflater inflater = (LayoutInflater)view.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v2 = inflater.inflate(R.layout.layer_favorite, null);
AlertDialog.Builder a = new AlertDialog.Builder(view.getContext());
a.setView(v2);
a.show();
a.setCancelable(true);

 

 Full Kode :

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
// setting data to our views of recycler view.
CourseModal modal = courseModalArrayList.get(position);
holder.courseNameTV.setText(modal.getCourseName());
holder.courseTracksTV.setText(modal.getCourseTracks());
holder.courseModeTV.setText(modal.getCourseMode());

//tombol baca
holder.btnBaca.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent MoveintentWithData = new Intent(view.getContext(), Baca.class);
view.getContext().startActivity(MoveintentWithData);

LayoutInflater inflater = (LayoutInflater)view.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v2 = inflater.inflate(R.layout.layer_favorite, null);
AlertDialog.Builder a = new AlertDialog.Builder(view.getContext());
a.setView(v2);
a.show();
a.setCancelable(true);
}
});
Picasso.get().load(modal.getCourseimg()).into(holder.courseIV);
}