I can't load image into ImageView
using Picasso
. I searched so much but I couldn't find answer.
There is a GridView
and GridView has an ImageView
and TextView
. I used Picasso to load image into ImageView.
Here is adapter:
public class MyGridAdapter extends BaseAdapter {
Context context;
LayoutInflater inflater;
public List<Photo> data ;
Photo photo = new Photo();
public MyGridAdapter(Context context,
List<Photo> arraylist) {
this.context = context;
data = arraylist;
//imageLoader = new ImageLoader(context);
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
public View getView(final int position, View convertView, ViewGroup parent) {
// Declare Variables
TextView phototitle;
ImageView imageView;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.gridview_item, parent, false);
// Get the position
photo = data.get(position);
phototitle = (TextView) itemView.findViewById(R.id.phototitle);
imageView = (ImageView) itemView.findViewById(R.id.imageView1);
phototitle.setText(photo.getTitle());
String url = photo.getUrl();
Log.d("url", url);
Picasso.with(context).setLoggingEnabled(true);
Picasso.with(context).load(url).into(imageView);
return itemView;
}
}
Here is GridView item:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ImageView
android:id="@+id/imageView1"
android:layout_width="200dp"
android:layout_height="200dp" />
<TextView
android:id="@+id/phototitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp"/>
</LinearLayout>
output:
12-23 22:03:03.921 18840-18840/com.mehmetsefa.challenge D/url: http://placehold.it/150/bb7f4
12-23 22:03:03.926 18840-18840/com.mehmetsefa.challenge W/Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
12-23 22:03:03.931 18840-18840/com.mehmetsefa.challenge D/Picasso: Main created [R0] Request{http://placehold.it/150/bb7f4}
12-23 22:03:03.936 18840-19224/com.mehmetsefa.challenge D/Picasso: Dispatcher enqueued [R0]+2ms
12-23 22:03:03.936 18840-19226/com.mehmetsefa.challenge D/Picasso: Hunter executing [R0]+2ms
12-23 22:03:03.946 18840-18840/com.mehmetsefa.challenge D/url: http://placehold.it/150/bb7f4
What do I wrong?