0
私は、realmの結果としてデータを取得し、それをrecyclerviewアイテムとして表示するrecyclerviewを持っています。私の考えは、ユーザーがアイテムをクリックすると、ボトムシートがポップアップしてdeatilsを表示するということです。bottom sheet recyclerview holder
onBindViewHolderでボトムシートにデータを渡してからonClickメソッドshow bottomsheetに渡す方法はありますか?おかげ
は、ここに私のコード
public class EmployeeRVAdapterTable extends RecyclerView.Adapter<EmployeeRVAdapterTable.EmployeeViewHolderTable> implements RealmChangeListener {
private RealmResults<Predavanja> mEmployees;
public EmployeeRVAdapterTable(RealmResults<Predavanja> employee) {
this.mEmployees = employee;
mEmployees.addChangeListener(this);
}
@Override
public EmployeeViewHolderTable onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.table_row_item, parent, false);
return new EmployeeViewHolderTable(view);
}
@Override
public void onBindViewHolder(EmployeeViewHolderTable holder, int position) {
Predavanja predavanja = mEmployees.get(position);
holder.tablename.setText(predavanja.getPredmetPredavanja());
holder.tabletype.setText(predavanja.getRasponVremena());
holder.tablemjesto.setText(predavanja.getDvorana());
switch (predavanja.getPredavanjeIme()){
case("Predavanja,"):
holder.tableboja.setBackgroundResource(R.color.blue_nice);
break;
case("Auditorne vježbe,"):
holder.tableboja.setBackgroundResource(R.color.green_nice);
break;
case("Kolokviji,"):
holder.tableboja.setBackgroundResource(R.color.purple_nice);
break;
case("Laboratorijske vježbe,"):
holder.tableboja.setBackgroundResource(R.color.red_nice);
break;
case("Konstrukcijske vježbe,"):
holder.tableboja.setBackgroundResource(R.color.grey_nice);
break;
case("Seminar,"):
holder.tableboja.setBackgroundResource(R.color.blue_nice);
break;
case("Ispiti,"):
holder.tableboja.setBackgroundResource(R.color.purple_dark);
break;
}
}
@Override
public int getItemCount() {
return mEmployees.size();
}
public class EmployeeViewHolderTable extends RecyclerView.ViewHolder implements View.OnClickListener{
TextView tablename, tabletype, tablemjesto;
RelativeLayout tableboja;
public EmployeeViewHolderTable(View itemView) {
super(itemView);
tablename = (TextView) itemView.findViewById(R.id.table_name);
tabletype = (TextView) itemView.findViewById(R.id.table_type);
tableboja = (RelativeLayout)itemView.findViewById(R.id.colorMe);
tablemjesto = (TextView)itemView.findViewById(R.id.table_mjesto);
itemView.setOnClickListener(this);
}
@Override
public void onClick(View view) {
Context context = view.getContext();
TextView info, info2,info3;
final BottomSheetDialog dialog;
View views = LayoutInflater.from(context).inflate(R.layout.bottom_sheep, null);
info = (TextView) views.findViewById(R.id.predavanjeImeDialog);
dialog = new BottomSheetDialog(context);
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
dialog.setContentView(views);
dialog.show();
}
}
@Override
public void onChange(Object element) {
notifyDataSetChanged();
}
}