当我点击RecyclerView
项目时,希望打开对话框。单击后的提示显示在屏幕上,但没有打开对话框。
代码:
public class Gridview_adapter extends RecyclerView.Adapter<Gridview_adapter.Myholder> {
private ArrayList<Photos_model> list;
private Activity ctx;
public Gridview_adapter(Activity ctx, ArrayList<Photos_model> list) {
this.list = list;
this.ctx = ctx;
}
@Override
public Gridview_adapter.Myholder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_gridview, parent, false);
return new Gridview_adapter.Myholder(view);
}
@Override
public void onBindViewHolder(Gridview_adapter.Myholder holder, int position) {
final Photos_model id = list.get(position);
Picasso.with(ctx).load(list.get(position).getImage()).resize(250, 400).into(holder.image);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ctx, "Selecteddddddddddddd upper", Toast.LENGTH_SHORT).show();
final Dialog dialog = new Dialog(ctx);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.image_perview);
}
});
}
@Override
public int getItemCount() {
return list.size();
}
public class Myholder extends RecyclerView.ViewHolder {
private ImageView image;
public Myholder(View itemView) {
super(itemView);
image = (ImageView) itemView.findViewById(R.id.gridimages);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
}
}
dialog.show();
。 - Piyush