Dies ist meine Adapterklasse, also in der onBindViewHolder
Methode.
Ich bin auf der Suche nach einer Möglichkeit, das geladene Bild von Picasso
an die NextActivity
zu senden.Senden eines Bildes von einer RecyclerView zur nächstenActivity in eine ImageView mit Picasso
package adapters;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import oerrride.we.huzykamz.ugentapp.CinemaViewHolders;
import oerrride.we.huzykamz.ugentapp.ItemObjects;
import oerrride.we.huzykamz.ugentapp.MovieScrollingActivity;
import oerrride.we.huzykamz.ugentapp.NtindaCinemaViewHolders;
import oerrride.we.huzykamz.ugentapp.R;
/**
* Created by HUZY_KAMZ on 7/22/2016.
*/
public class NtindaCinemaAdapter extends RecyclerView.Adapter<NtindaCinemaViewHolders> {
private String url="http://10.0.2.2/UgandaEntertainment/Ntinda/NtindaPics/";
private List<ItemObjects> itemList = null;
private Context context;
public View root = null ;
private ArrayList<ItemObjects> arraylist;
public NtindaCinemaAdapter(Context context, List<ItemObjects> itemList) {
this.itemList = itemList;
this.context = context;
}
@Override
public NtindaCinemaViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.ntinda_cinema_list, parent,false);
NtindaCinemaViewHolders rcv = new NtindaCinemaViewHolders(layoutView,context);
return rcv;
}
@Override
public void onBindViewHolder(NtindaCinemaViewHolders holder, final int position) {
final ItemObjects feedItem = itemList.get(position);
holder.root.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(NtindaCinemaAdapter.this.context, MovieScrollingActivity.class);
intent.putExtra(NtindaCinemaViewHolders.KEY_SYNOPSIS, feedItem.getSynopsis());
intent.putExtra(NtindaCinemaViewHolders.KEY_MOVIE_IMAGE, feedItem.getPhoto()+url);
context.startActivity(intent);
}
});
//Download image using picasso library
Picasso.with(context).load(url+feedItem.getPhoto())
.error(R.drawable.placeholder).
resize(500,500)
.placeholder(R.drawable.placeholder)
.into(holder.moviepic);
holder.moviename.setText(itemList.get(position).getMovieName());
}
@Override
public int getItemCount() {
return (null != itemList ? itemList.size() : 0);
}
}
Das ist mein nextActivity, und wie ich es hier
package oerrride.we.huzykamz.ugentapp;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
public class MovieScrollingActivity extends AppCompatActivity {
TextView synpsis_txt;
ImageView image;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling);
getSupportActionBar().setDisplayShowHomeEnabled(false);
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.hide();
// declarations
Intent getImage = getIntent();
String gettingImageUrl = getImage.getStringExtra(NtindaCinemaViewHolders.KEY_MOVIE_IMAGE);
synpsis_txt = (TextView) findViewById(R.id.synopsis_txt);
image = (ImageView) findViewById(R.id.image_movie_scroll);
Bundle bundle = getIntent().getExtras();
synpsis_txt.setText(bundle.getString(NtindaCinemaViewHolders.KEY_SYNOPSIS));
Picasso.with(MovieScrollingActivity.this).load(gettingImageUrl).error(R.drawable.placeholder).
resize(500,500)
.placeholder(R.drawable.placeholder).into(image);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab2);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Yah, aber es ist ein anderes Problem, können Sie mir helfen –