hi im still new to android i was displaying some dummy images in a grid view, i have a custom adapter that uses a view holder, it puts a string array and type array into an array list and displays it in the gridview this all works fine, then i realised my images i wanted to use were far too large and found the picasso library, seems very powerful and easy to use but im unsure what to pass into the load method as it wants a type array and my type array is in an array list im sure this is a simple fix but i cant see it, my images are in the app
here is my imageId and viewholder class
class imageIds
{
int imageId;
String imageNames;
imageIds(int imageId, String imageNames)
{
this.imageId = imageId;
this.imageNames = imageNames;
}
}
class ViewHolder
{
ImageView myView;
ViewHolder(View view){
myView = (ImageView) view.findViewById(R.id.imageView);
}
}
this is the beginning of my adapter where i declare and initialize my arrays
class myAdapter extends BaseAdapter{
ArrayList<imageIds> list;
Context context;
myAdapter(Context context)
{
this.context = context;
list = new ArrayList<imageIds>();
Resources res = context.getResources();
String[] tempWallpaperNames = res.getStringArray(R.array.wallpaper_list);
int[] tempWallPaperImages = {R.drawable.ic_home,R.drawable.ic_photos,R.drawable.ic_home,
R.drawable.ic_photos,R.drawable.ic_photos,R.drawable.ic_photos,R.drawable.ic_home,
R.drawable.ic_home,R.drawable.ic_photos,R.drawable.ic_home};
for (int i = 0; i<10;i++)
{
imageIds tempWallpaper = new imageIds(tempWallPaperImages[i],tempWallpaperNames[i]);
list.add(tempWallpaper);
}
}
and here is my adapter get view method
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
ViewHolder holder = null;
if (row == null){
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.grid_images,parent,false);
holder = new ViewHolder(row);
row.setTag(holder);
}
else{
holder = (ViewHolder) row.getTag();
}
imageIds wallPapers = list.get(position);
holder.myView.setImageResource(wallPapers.imageId);
holder.myView.setTag(wallPapers);
Picasso.with(getActivity())
.load(imageIds[position])
.placeholder(R.drawable.ic_photos)
.error(R.drawable.ic_drawer)
.noFade().resize(120,120)
.centerCrop().into(holder.myView);
return holder.myView;
return row;
}
}
android studio is telling me an expression is expected here
.load(imageIds[position])
thanks for any help