こんにちは私は、このJSONデータa linkrecyclerviewから選択した画像はどのように知りますか?
を持っていると私は、これはJSONの作品です
にjsonArrayを解析し、
"im:image":[
{
"label":"http://is1.mzstatic.com/image/thumb/Purple20/v4/87/35/82/87358231-ce91-3d14-b306-95888c23db3c/mzl.gdgtivnk.png/53x53bb-85.png",
"attributes":{
"height":"53"
}
},
{
"label":"http://is5.mzstatic.com/image/thumb/Purple20/v4/87/35/82/87358231-ce91-3d14-b306-95888c23db3c/mzl.gdgtivnk.png/75x75bb-85.png",
"attributes":{
"height":"75"
}
},
{
"label":"http://is3.mzstatic.com/image/thumb/Purple20/v4/87/35/82/87358231-ce91-3d14-b306-95888c23db3c/mzl.gdgtivnk.png/100x100bb-85.png",
"attributes":{
"height":"100"
}
}
が、同じように扁平部ここの画像をクリックすると、この画像が得られます!私はこの問題を解決し、私はスナップ用の画像を得た「snapchat」に私をクリックしたときにできる方法
?
これはJSON
public void JsonAppShowData() {
final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(jsonUrl, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) { try {
JSONArray jsonArray = response.getJSONObject(feedKey).getJSONArray(entryKey);
AppShowModule appShowModule = new AppShowModule();
int x = appShowModule.getId();
for (int i = 0; i<jsonArray.length();i++)
{
JSONArray imageArray = response.getJSONObject(feedKey).getJSONArray(entryKey).getJSONObject(i).getJSONArray(imageKey);
for (int j = 0; j < imageArray.length(); j++) {
String image = imageArray.getJSONObject(j).getString(labelKey).toString();
imageUrls.add(image);
appShowModule.setAllimage(imageUrls);
appShowModules.add(appShowModule);
}}
imageRecyclerViewadapter = new ImageListAdapter(appShowModules, getContext(), imageUrls);
AppRecyclerView.setAdapter(imageRecyclerViewadapter);
} catch (JSONException e) {
e.printStackTrace();
}}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("LOG", error.toString());
}
});
を解析すると、これは画像一覧ローダー
public class ImageListAdapter extends RecyclerView.Adapter<ImageListAdapter.ViewHolder> {
List<AppShowModule> appShowModules;
List<String> imageUrl;
AppShowModule appShowModule;
String x;
Context context;
public ImageListAdapter(List<AppShowModule> appShowModules, Context context ,List<String>imageUrls
){
super();
this.imageUrl =imageUrls;
this.appShowModules = appShowModules;
this.context = context;}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.imagelayout, parent,false);
ViewHolder viewHolder = new ViewHolder(v);
return viewHolder;}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
AppShowModule appShowModule = appShowModules.get(position);
x = appShowModule.getAllimage().get(position);
Picasso.with(context).load(x).into(holder.appImage);
}
public int getItemCount() {
return imageUrl.size();
}
class ViewHolder extends RecyclerView.ViewHolder {
public ImageView appImage;
public ViewHolder(View itemView) {
super(itemView);
appImage = (ImageView) itemView.findViewById(R.id.appImage);
appImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent= new Intent(context, ImageShow.class);
intent.putExtra("image", x);
context.startActivity(intent);
}});
}
}
}
であり、これはあなたが直接することはできません
appImage=(ImageView)findViewById(R.id.appImage);
Picasso.with(context).load(x).into(appImage);
このコードはonBindViewHolder にあると私はgetAdapterPositionを())を追加してみてください。ビューホルダーにそのconnot reslove! –