不明な質問がありました。私はアンドロイドとスタックオーバーフローの新人ですアダプターからアクティビティーへの意向
私は、サーバーの画像と負荷のリストを持っているアダプタを持っています。 画像のOnclickには、クリックしたアイテムのフルイメージを示す別のアクティビティを開く必要があります。その時点で 私は意図として次の活動に画像のURLを渡す必要があります。 私は意図を渡す際に助けを必要とするだけでなく、私を明確にしてくださいアダプタからアクティビティへの意図でイメージURLを渡すことは安全ですか? holder.text_promise(イメージ図)をクリックする上で事前に助けを おかげ
私のアダプタクラス
ここclass MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>{
List<Upload> list_of_messages;
Context context;
Activity mActivity;
PhotoViewAttacher pAttacher;
public MyAdapter(Activity activity,List<Upload> list_of_messages,Context context) {
this.mActivity = activity;
this.list_of_messages = list_of_messages;
this.context=context;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_promise_list,parent,false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(final MyAdapter.ViewHolder holder, final int position) {
final Upload upload = list_of_messages.get(position);
holder.text_date.setText(upload.getName());
Glide.with(context).load(upload.getUrl()).into(holder.text_promise);
final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
holder.text_promise.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(mActivity,ImageViewZoom.class);
intent.putExtra("image_url",upload.getUrl());
context.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return list_of_messages.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView text_date;
ImageView text_promise;
public ViewHolder(View itemView) {
super(itemView);
text_promise=itemView.findViewById(R.id.text_promise_text);
text_date=itemView.findViewById(R.id.text_promise_date);
}
}
public void onImageClicked(Activity a, String url) {
a.startActivity(new Intent(a, FullScreenImageActivity.class).putExtra("image_url", url));
a.overridePendingTransition(android.R.anim.fade_in, 1);
}
}
iはImageViewZoomアクティビティに移動する必要があり、そこに私は、アダプタからイメージをロードする必要があります。
私は混乱して助けを求めました。
試したコードを追加してください –