Answer the question
In order to leave comments, you need to log in
How to open pictures in picasso to the entire screen area?
Hello everyone. There was a need when clicking on images loaded with picasso, to open to most of the screen area. But setImageResource is incompatible with String.
public class GridViewAdapter extends BaseAdapter {
private Context context;
public String[] items = {
"http://topmemas.top/img/img/1517414160.jpg",
"http://topmemas.top/img/img/1518633309.jpg",
"http://topmemas.top/img/img/1517859960.jpg",
};
public GridViewAdapter(Context context){
this.context=context;
}
@Override
public int getCount() {
return items.length;
}
@Override
public Object getItem(int position) {
return items[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertview, ViewGroup parent) {
ImageView img;
if (convertview == null){
img = new ImageView(context);
convertview = img;
img.setPadding(10,10,10,10);
}else {
img =(ImageView)convertview;
}
Picasso.with(context).load(items[position]).placeholder(R.drawable.image)
.resize(320,320)
.into(img);
return convertview;
}
}
public class FullImageActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_full_image);
Intent i =getIntent();
int position=i.getExtras().getInt("id");
GridViewAdapter adapter = new GridViewAdapter(this);
ImageView img=(ImageView)findViewById(R.id.imageViewfull);
img.setImageResource(adapter.items[position]);
}
Error:(23, 43) error: incompatible types: String cannot be converted to int
public class FragmentMems extends android.support.v4.app.Fragment {
private GridView gridView;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_user_mems, container, false);
gridView = (GridView) rootView.findViewById(R.id.gridview);
gridView.setAdapter(new GridViewAdapter(getContext()));
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
Intent i =new Intent(getContext(),FullImageActivity.class);
i.putExtra("id",position);
startActivity(i);
}
}); return rootView;
}
}
Answer the question
In order to leave comments, you need to log in
If you don't have resources, but urls, then obviously you do NOT need to use methods that take a resource identifier. And why don't you use picasso to load a large image the same way you do it in an adapter?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question