_____ _ _ _ _____ _ _ _____ _ _____ _____ _ _ _ _____ _ _ _ | _ | ___ _| | ___ ___ |_| _| | | __| ___ |_| _| || | ||_| ___ _ _ _ | | _ _ ___ ___ ___ ___ | _ | _| | ___ ___ | |_ ___ ___ ___ ___ _| | | | _____ ___ ___ ___ _ _ |_| ___ _ _ _ ___ |_| ___ |_| ___ ___ | || || . || _|| . || || . | | | || _|| || . || | || || -_|| | | | _ | --|| | || _||_ -|| . || _|| || . || .'|| . || _|| -_|| _| | .'|| || . | |- -|| || .'|| . || -_|| | || || -_|| | | | |_ -|| ||- _|| || || . | _ |__|__||_|_||___||_| |___||_||___| |_____||_| |_||___| \___/ |_||___||_____|| | |_____||___||_| |___||___||_| |__|__||___||__,|| _||_| |___||_| |__,||_|_||___| |_____||_|_|_||__,||_ ||___| \_/ |_||___||_____| |___||_||___||_||_|_||_ ||_| |_| |_| |___| |___|
Alright, a geeky post for today, and in English so it might be useful to someone, maybe.
I had a problem with my GridView content jumping around, and here is how I fixed it :
public class PhotosGridAdapter extends CursorAdapter {
public PhotosGridAdapter(Context context, Cursor c) {
super(context, c);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
ImageView photo = (ImageView) view;
String url_medium = cursor.getString(cursor.getColumnIndex(KarmaDbAdapter.PHOTO_URL_MEDIUM));
ImageCache.download(url_medium, photo);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
ImageView v = new ImageView(context);
v.setLayoutParams(new GridView.LayoutParams(100, 100));
v.setScaleType(ImageView.ScaleType.FIT_CENTER);
bindView(v, context, cursor);
return v;
}
}
Basically you need to set the layout params in the newView, and not in the bindView, otherwise the previous content get shrank down.
There you go, I’m going back to my nexus.