我如何获得装载毕加索的iml的url并将其传递给Recyclerview适配器中的另一个活动?
我没有找到任何从毕加索获取网址的东西,所以如果有人可以帮助我,请在这篇帖子上告诉我一个metod或代码,谢谢你
package com.roa.nox.store.adapters;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.roa.nox.store.ApActivity;
import com.roa.nox.store.ItemObjectC;
import com.roa.nox.store.R;
import com.roa.nox.store.models.SingleItemModel;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.Locale;
import me.drakeet.materialdialog.MaterialDialog;
public class SectionListDataAdapter extends RecyclerView.Adapter<SectionListDataAdapter.SingleItemRowHolder> {
private ArrayList<SingleItemModel> itemsList;
private Context mContext;
private boolean isLang;
public SectionListDataAdapter(Context context, ArrayList<SingleItemModel> itemsList) {
this.itemsList = itemsList;
this.mContext = context;
}
@Override
public SingleItemRowHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.list_single_card, null);
SingleItemRowHolder mh = new SingleItemRowHolder(v);
return mh;
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public void onBindViewHolder(SingleItemRowHolder holder, int i) {
SingleItemModel singleItem = itemsList.get(i);
final int p= singleItem.getPrice();
if(p==0)
{
if (isLang = Locale.getDefault().getLanguage().equals("fa")) {
holder.price.setText("رایگان");
} else {
holder.price.setText("Free");
}
}
else
{
holder.price.setText(String.valueOf(p));
}
double rate=singleItem.getRate();
String srate= String.valueOf(rate);
holder.tvTitle.setText(singleItem.getName());
holder.dvt.setText(singleItem.getdv());
holder.cat.setText(singleItem.getcat());
holder.url.setText(singleItem.getUrl());
holder.icon.setText(singleItem.geticon());
Picasso.with(mContext).load(singleItem.geticon()).placeholder(R.drawable.load).error(R.drawable.error).into(holder.itemImage);
holder.cont.setText(singleItem.getContent());
holder.rte.setText(srate);
/* Glide.with(mContext)
.load(feedItem.getImageURL())
.diskCacheStrategy(DiskCacheStrategy.ALL)
.centerCrop()
.error(R.drawable.bg)
.into(feedListRowHolder.thumbView);*/
}
@Override
public int getItemCount() {
return (null != itemsList ? itemsList.size() : 0);
}
public class SingleItemRowHolder extends RecyclerView.ViewHolder {
protected ImageButton btaction;
protected TextView rte;
protected TextView cat;
protected TextView price;
protected TextView tvTitle;
protected TextView dvt;
protected TextView url;
protected TextView icon;
protected TextView cont;
protected ImageView itemImage;
private Context context;
private int p;
public SingleItemRowHolder(View view) {
super(view);
this.tvTitle = (TextView) view.findViewById(R.id.tvTitle);
this.dvt = (TextView) view.findViewById(R.id.tdv);
this.price = (TextView) view.findViewById(R.id.price);
this.url = (TextView) view.findViewById(R.id.url);
this.cont = (TextView) view.findViewById(R.id.content);
this.itemImage = (ImageView) view.findViewById(R.id.itemImage);
this.btaction = (ImageButton) view.findViewById(R.id.action);
this.rte = (TextView) view.findViewById(R.id.raten);
this.cat = (TextView) view.findViewById(R.id.cat);
this.icon = (TextView) view.findViewById(R.id.icon);
view.setOnClickListener(new View.OnClickListener() {
public ItemObjectC parseImageFile;
public String iconi;
@Override
public void onClick(View v) {
final String URL = url.getText().toString();
final int pos = getAdapterPosition();
Intent intent = new Intent(mContext, ApActivity.class);
intent.putExtra("name", tvTitle.getText().toString());
intent.putExtra("price", price.getText().toString());
intent.putExtra("content", cont.getText().toString());
intent.putExtra("dev", dvt.getText().toString());
intent.putExtra("cat", cat.getText().toString());
intent.putExtra("icon", What i should to add for get url???);
intent.putExtra("rate", rte.getText().toString());
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
mContext.startActivity(intent);
}
});
btaction.setOnClickListener(new View.OnClickListener() {
@SuppressLint("NewApi")
@Override
public void onClick(View v) {
PopupMenu popup = new PopupMenu(mContext, v);
popup.getMenuInflater().inflate(R.menu.popup,
popup.getMenu());
popup.show();
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.install:
break;
case R.id.addtowishlist:
break;
default:
break;
}
return true;
}
});
}
});
}
}}
答案 0 :(得分:1)
如果不自己修改Picasso图书馆,就无法做到这一点。幸运的是,常用和易于实现的解决方法。只需使用商品的ID /位置标记可点击元素即可。例如(如果holder.itemImage是可点击的),在onBindViewHolder()中:
holder.itemImage.setTag(position);
然后,在onClick()或处理点击的任何地方:
int position = (int) v.getTag();
String iconUrl = adapter.itemsList.get(position).geticon(); // make itemsList public or provide getter first
答案 1 :(得分:0)
你可以像这样制作二传:
holder.setImage(Arraylist<String> array ,Int position) {
Arraylist<String> url = new Arraylist<String>();
url = array.get(position);
Picasso.with(mContext).load(url).into(image_view); }
并在您的方法中:
public void onBindViewHolder(SingleItemRowHolder holder, int i) {
...
holder.setImage(your_array,i);
...
}