I have created a simple Custom dialog
class and I want to display it after clicking on a row in RecycleView
.
My dialog class looks:
public class AddToQueueDialog extends Dialog implements View.OnClickListener {
Activity mActivity;
private TextView textView1;
private TextView textView2;
private Button save;
public AddToQueueDialog(Activity activity){
super(activity);
mActivity = activity;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_to_queue);
textView1 = (TextView) findViewById(R.id.textView5);
textView2 = (TextView) findViewById(R.id.textView6);
save = (Button) findViewById(R.id.button4);
save.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if(v.getId() == save.getId()){
Log.d("save", "save");
}
}
}
And I'm wondering how to properly call in adapter
of RecycleView
which looks:
(piece)
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public ViewHolder(Context context, View itemView, List<WashLocation> washLocations) {
super(itemView);
this.context = context;
info = (TextView) itemView.findViewById(R.id.textView);
favorite = (Button) itemView.findViewById(R.id.addToFav);
favorite.setOnClickListener(this);
info.setOnClickListener(this);
this.washLocations = washLocations;
dataBaseHelper = new DataBaseHelper(context);
}
@Override
public void onClick(View v) {
if(v.getId() == info.getId()){
AddToQueueDialog addToQueueDialog = new AddToQueueDialog(MapsActivity.this);
addToQueueDialog.show();
}
In my Custom dialog
class I need an Activity
in arg as a constructor but I don't know which Activity
should I pass there in Adapter
class
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…