In Activity I have 1 Fragment with ListView. In ListView photos. When you change tabs in the Activity, the content of the ListView (which is in Fragment) changes. Photos remain in memory and an OutOfMemory error occurs. I need your help, thank you.
public class MySimpleCursorAdapter extends SimpleCursorAdapter { private LayoutInflater mLayoutInflater; private Context context; private int layout; private class ViewHolder { ImageView mphoto; TextView id; TextView title; ViewHolder(View v) { id = (TextView) v.findViewById(R.id.id); mphoto = (ImageView) v.findViewById(R.id.mphoto); title = (TextView) v.findViewById(R.id.title); } } public MySimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int i) { super(context, layout, c, from, to); this.context = context; this.layout = layout; mLayoutInflater = LayoutInflater.from(context); } @Override public View newView(Context ctx, Cursor cursor, ViewGroup parent) { View vView = mLayoutInflater.inflate(layout, parent, false); vView.setTag( new ViewHolder(vView) ); return vView; } @Override public void bindView(View v, Context ctx, Cursor c) { int index_id = c.getColumnIndex(DataBaseHelper.C_ID); int index_photo = c.getColumnIndex(DataBaseHelper.C_MPHOTO); int index_title = c.getColumnIndex(DataBaseHelper.C_TITLE); String string_photo = c.getString(index_photo); String string_id = c.getString(index_id); String string_title = c.getString(index_title); ViewHolder vh = (ViewHolder) v.getTag(); vh.mphoto.setImageURI(Uri.parse("android.resource://com.aaa.aaaaa/drawable/" + string_photo)); vh.id.setText(string_id); vh.title.setText(string_title); } }
ListView- miha_devListView? or in each different? if different, they have the same adapters? - miha_dev