0
我想從我的ercyclerview片段發送一個圖像到活動現在我不知道如何做到這一點。新手()。 這是我的適配器發送btimap到另一個活動
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.r_view, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final Place place = new PlaceData().propertyList().get(position);
holder.homeTextView.setText(place.name);
holder.address.setText(place.addressname);
holder.prices.setText(place.prices);
//loading image to the main home imageview
Picasso.with(mcontext).load(path).fit().centerCrop().into(holder.mainImageview);
holder.mainImageview.
}
@Override
public int getItemCount() {
return new PlaceData().propertyList().size();
}
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public LinearLayout mainHolder;
public LinearLayout placeNameHolder;
public ImageView mainImageview;
public TextView homeTextView, address, prices;
public ViewHolder(View itemView) {
super(itemView);
mainImageview = (ImageView) itemView.findViewById(R.id.placeImage);
placeNameHolder = (LinearLayout) itemView.findViewById(R.id.placeNameHolder);
mainHolder = (LinearLayout) itemView.findViewById(R.id.mainHolder);
homeTextView = (TextView) itemView.findViewById(R.id.placeName);
address = (TextView) itemView.findViewById(R.id.propertyaddress);
prices = (TextView) itemView.findViewById(R.id.priceid);
mainHolder.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (itemClickListener != null) {
itemClickListener.onItemClick(itemView, getPosition());
}
}
}
public interface onItemClickListener {
void onItemClick(View v, int position);
}
public void setOnItemClickListener(final onItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
,這我的片段
//oclick listener for the recylerview in the fragment
MainAdaptor.onItemClickListener OnItemClickListener = new MainAdaptor.onItemClickListener(){
@Override
public void onItemClick(View v, int position) {
Intent intent = new Intent(getContext(),Details.class);
intent.putExtra(Details.EXTRA_PARAM_ID,position);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
}
};
我想這樣做是什麼,當點擊recyclerview產品進入活動的ImageView
在哪裏如果您的意思是'getIntent'部分只是將其添加到第二個Activity中,那麼我會將第二個代碼片段放在recyclerview – droid501
中嗎?或者您的意思是'Intent' ** S tring **只是創建路徑變量('私人字符串路徑;')並把'意圖'你有'ClickListener'像'onItemClick'和'請更清楚你的問題' – Hosseini
謝謝你,我設法了它,我我在Android新,所以有時我的問題有點抽象,我會嘗試更具體。再次感謝 – droid501