Android ImageAdapter repeating the same images/items again and again - java

The ImageAdapter code I used to display images from my SD card to a GridView causes the images to repeat. The same set of images, like 10 of them are repeated in the GridView.
Here's my Adapter code:
private class ImageAdapter extends BaseAdapter {
private Context context;
public ImageAdapter(Context localContext) {
context = localContext;
}
public int getCount() {
return cursor.getCount();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView picturesView;
if (convertView == null) {
picturesView = new ImageView(context);
// Move cursor to current position
cursor.moveToPosition(position);
// Get the current value for the requested column
int imageID = cursor.getInt(columnIndex);
// Set the content of the image based on the provided URI
picturesView.setImageURI(Uri.withAppendedPath(
MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, "" + imageID));
picturesView.setScaleType(ImageView.ScaleType.CENTER_CROP);
picturesView.setPadding(0, 0, 0, 0);
picturesView.setLayoutParams(new GridView.LayoutParams(300, 300));
}
else {
picturesView = (ImageView)convertView;
}
return picturesView;
}
}
Additionally, here's the code that calls the Adapter in order to display all my SD Card images in the GridView
String[] projection = {MediaStore.Images.Thumbnails._ID};
// Create the cursor pointing to the SDCard
cursor = managedQuery( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
projection, // Which columns to return
null, // Return all rows
null,
MediaStore.Images.Thumbnails._ID);
// Get the column index of the Thumbnails Image ID
columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);
GridView sdcardImages = (GridView) findViewById(R.id.sdcard);
sdcardImages.setAdapter(new ImageAdapter(this));
// Set up a click listener
sdcardImages.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
// Get the data location of the image
String[] projection = {MediaStore.Images.Media.DATA};
cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection, // Which columns to return
null, // Return all rows
null,
null);
columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToPosition(position);
// Get image filename
String imagePath = cursor.getString(columnIndex);
// Use this path to do further processing, i.e. full screen display
}
});
What is wrong with my code guys?

In case the view is recycled and convertView is not null, you are not resetting the image URI. This is why you seeing just the images for which the view had to be created from scratch as convertView was null.
Therefore reuse or create a new view if needed :
final ImageView picturesView = convertView == null ? new ImageView(context) : (ImageView) convertView;
and later on configure it as you want.
But it is far more easier in you case to inherit behavior from CursorAdapter rather than BaseAdapter abstract class :
private class ImageAdapter extends CursorAdapter {
private final int columnIndex;
public ImageAdapter(Context context, Cursor cursor) {
super(context, cursor, true);
columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return new ImageView(context);
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
final ImageView picturesView = (ImageView) view;
final int imageID = cursor.getInt(columnIndex);
final Uri uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, String.valueOf(imageID));
picturesView.setImageURI(uri);
picturesView.setScaleType(ImageView.ScaleType.CENTER_CROP);
picturesView.setPadding(0, 0, 0, 0);
picturesView.setLayoutParams(new GridView.LayoutParams(300, 300));
}
}

Related

How can I use recyclerviewadapter with sqlite in android?

I have an SQLite database in android. I couldn't be able to see image data in RecyclerView. How can I see that in the activity page with a RecyclerView adapter?
I tried this but EpisodesAdapter episodesAdapter = new EpisodeAdapter(this, cursorEpisode, 0); this line is giving an error.
try {
EpisodesAdapter episodesAdapter = new EpisodeAdapter(this,cursorEpisode,0);
rvEpisodeImage.setAdapter(episodesAdapter);
Toast.makeText(this, "Succeed", Toast.LENGTH_SHORT).show();
} catch (SQLException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
This is the adapter class
public class EpisodesAdapter extends RecyclerView.Adapter<EpisodesAdapter.ViewHolder> {
private CursorAdapter mEpisodesAdapter;
private Context mEpisodesContext;
private RecyclerView.ViewHolder holder;
public EpisodesAdapter(final Context mEpisodesContext, Cursor cursor) {
this.mEpisodesContext = mEpisodesContext;
mEpisodesAdapter = new CursorAdapter(mEpisodesContext, cursor,0 ) {
#Override
public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
// Inflate the view here
View view = LayoutInflater.from(context).inflate(R.layout.list_of_parts,viewGroup, false);
return view;
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
ImageView ivParts = view.findViewById(R.id.ivParts);
String sEpisodeName = cursor.getString(cursor.getColumnIndexOrThrow("EPISODE_NAME"));
int iImgPath = (int) context.getResources().getIdentifier(sEpisodeName, "drawable", context.getPackageName());
ivParts.setImageResource(iImgPath);
}
};
}
#NonNull
#Override
public EpisodesAdapter.ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = mEpisodesAdapter.newView(mEpisodesContext, mEpisodesAdapter.getCursor(), parent);
holder = new ViewHolder(view);
return (ViewHolder) holder;
}
#Override
public void onBindViewHolder(#NonNull EpisodesAdapter.ViewHolder holder, int position) {
mEpisodesAdapter.getCursor().moveToPosition(position);
mEpisodesAdapter.bindView(holder.itemView,mEpisodesContext,mEpisodesAdapter.getCursor());
}
#Override
public int getItemCount() {
return mEpisodesAdapter.getCount();
}
public static class ViewHolder extends RecyclerView.ViewHolder{
private ImageView ivParts;
public ViewHolder(#NonNull View itemView) {
super(itemView);
ivParts = itemView.findViewById(R.id.ivParts);
}
}
}
What am I missing here? What should I do to get a view in RecyclerView?
EpisodesAdapter episodesAdapter = new EpisodeAdapter(this, cursorEpisode, 0);
I would like to suggest you read the values from the cursor first and save the values in an ArrayList. Then pass the ArrayList to the adapter instead of passing the cursor.
The problem in your adapter is, you should get the same value from the cursor for every item in your RecyclerView as you are not actually iterating over the cursor when the position changes. The Cursor works as a pointer and hence you need to move to the next pointer to get the next element in your cursor. Hence I would like to suggest something like the following.
Declare a class to handle your data first.
public class Episode {
public String episodeName;
public int imagePath;
}
Then after getting the cursor from your database, iterate through the cursor and populate an ArrayList of Episode like the following.
public ArrayList<Episode> getEpisodesFromCursor(Cursor cursor, Context context) {
ArrayList<Episode> episodes = new ArrayList<Episode>();
if (cursor == null) return episodes;
cursor.moveToFirst();
do {
Episode episode = new Episode();
String episodeName = cursor.getString(cursor.getColumnIndexOrThrow("EPISODE_NAME"));
episode.episodeName = episodeName;
episode.imagePath = (int) context.getResources().getIdentifier(episodeName, "drawable", context.getPackageName());
episodes.add(episode);
} while(cursor.moveToNext());
return episodes;
}
Pass the cursor to the function above to get an ArrayList of your items. Then modify your adapter to accept the ArrayList<Episode> and then change your other functions accordingly.
Once you have passed the ArrayList, modify the bindView function accordingly to show proper image and other data.
#Override
public void bindView(View view, Context context, int position) {
ImageView ivParts = view.findViewById(R.id.ivParts);
String sEpisodeName = episodes.get(position).episodeName;
int iImgPath = (int) context.getResources().getIdentifier(sEpisodeName, "drawable", context.getPackageName());
ivParts.setImageResource(iImgPath);
}
I just have added some sample implementation and you need to change the code as per your need. I hope that helps!
Edit:
Moreover, you are getting the error as the adapter constructor is expecting different parameters. You need to modify the constructor of your adapter anyway if you are using an ArrayList as I have suggested.

Loading image from sqllite does not appear

I have an app that loads data from a sqllite database, then converts the data to appropriate formats so it could pass on the data to fragment tabs.
Everything works fine except for the images.
In the DB images are stored in full path, for example R.drawable.muntjakas and the images are available in the resource drawable folder.
The app pulls the data from the db and then converts it to int format so it could be passed on. Eclipse is not giving me any errors, but when the app loads images are not displayed. My xml files have the image id set up and displays the images if I assign the values manually for example
flag = new int[] { R.drawable.muntjakas,.... };
What's the problem?
fragmenttab1.java class that loads data from sql and converts it:
public class FragmentTab1 extends SherlockFragment {
ListView list;
ListViewAdapter adapter;
private static final String DB_NAME = "animalsDB.sqllite3";
private static final String TABLE_NAME = "animals";
private static final String ANIMAL_ID = "_id";
private static final String ANIMAL_NAME = "name";
private static final String ANIMAL_PIC = "pic";
public static final String[] ALL_KEYS = new String[] {ANIMAL_ID, ANIMAL_NAME,ANIMAL_PIC };
private SQLiteDatabase database;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragmenttab1, container,
false);
ExternalDbOpenHelper dbOpenHelper = new ExternalDbOpenHelper(getActivity(), DB_NAME);
database = dbOpenHelper.openDataBase();
Cursor cursor = getAllRows();
ArrayList<String> nameArray = new ArrayList<String>();
ArrayList<Integer> picArray = new ArrayList<Integer>();
for(cursor.moveToFirst(); cursor.moveToNext(); cursor.isAfterLast()) {
nameArray.add(cursor.getString(cursor.getColumnIndex(ANIMAL_NAME)));
picArray.add(cursor.getInt(cursor.getColumnIndex(ANIMAL_PIC)));
}
final String[] name = (String[]) nameArray.toArray(new String[nameArray.size()]);
final Integer[] pic = (Integer[]) picArray.toArray(new Integer[picArray.size()]);
final int[] flag = new int[pic.length];
for (int i = 0; i < pic.length; i++ ) {
flag[i] = pic[i];
}
// Locate the ListView in fragmenttab1.xml
list = (ListView) rootView.findViewById(R.id.listview);
// Pass results to ListViewAdapter Class
adapter = new ListViewAdapter(getActivity(), name, flag);
// Binds the Adapter to the ListView
list.setAdapter(adapter);
// Capture clicks on ListView items
list.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// Send single item click data to SingleItemView Class
Intent i = new Intent(getActivity(), SingleItemView.class);
// Pass all data country
i.putExtra("country", name);
// Pass all data flag
i.putExtra("flag", flag);
// Pass a single position
i.putExtra("position", position);
// Open SingleItemView.java Activity
startActivity(i);
}});
return rootView;
}
public Cursor getAllRows() {
String where = null;
Cursor c = database.query(true, TABLE_NAME, ALL_KEYS,
where, null, null, null, null, null);
if (c != null) {
c.moveToFirst();
}
return c;
}
}
My listViewAdapter.java class that should load the data on the screen:
package kf.kaunozoo;
public class ListViewAdapter extends BaseAdapter {
// Declare Variables
Context context;
String[] country;
int[] flag;
LayoutInflater inflater;
public ListViewAdapter(Context context, String[] country, int[] flag) {
this.context = context;
this.country = country;
this.flag = flag;
}
public int getCount() {
return country.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
// Declare Variables
TextView txtcountry;
ImageView imgflag;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.listview_item, parent, false);
// Locate the TextViews in listview_item.xml
txtcountry = (TextView) itemView.findViewById(R.id.country);
// Locate the ImageView in listview_item.xml
imgflag = (ImageView) itemView.findViewById(R.id.flag);
// Capture position and set to the TextViews
txtcountry.setText(country[position]);
// Capture position and set to the ImageView
imgflag.setImageResource(flag[position]);
return itemView;
}
}
What am I doing wrong? All answers are appreciated
I have had this problem once in one of my apps, however, what I did was, I saved unique ids for each drawable in database as I had limited images. While displaying I wrote a small function where I used switch statement to check for each id from database and then loaded images accordingly in ImageView.
However, when you have lots of images, try to use below function, where you can provide image names dynamically from database.
// image from res/drawable
int resID = getResources().getIdentifier("your_image_name",
"drawable", getPackageName());
Also, you may try the solution given at this blog.

Android Listview Caching work unexpectedly on initialization

I have a bit troublesome with view caching in listview (a.k.a convertView)
so here is my code,
private class CurrencyAdapter extends ArrayAdapter<CurrencyModel> {
Context ctx;
int layoutResourceId;
List<CurrencyModel> adapter_models = null;
public CurrencyAdapter(Context ctx, int layoutResourceId,
List<CurrencyModel> model) {
super(ctx, layoutResourceId, model);
this.ctx = ctx;
this.layoutResourceId = layoutResourceId;
adapter_models = model;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Log.d(Constants.APP_TAG, "position: " + position);
View row = convertView;
CurrencyAdapterContainer holder = null;
if (row == null) {
Log.d(Constants.APP_TAG, "APP NULL");
row = ((Activity) ctx).getLayoutInflater().inflate(
layoutResourceId, parent, false);
holder = new CurrencyAdapterContainer();
holder.textView = (TextView) row
.findViewById(R.id.currencies_txt);
holder.imgView = (ImageView) row
.findViewById(R.id.currencies_flag_icon);
row.setTag(holder);
} else {
Log.d(Constants.APP_TAG, "APP NOT NULL");
holder = (CurrencyAdapterContainer) row.getTag();
}
CurrencyModel curr = getItem(position);
if (curr.currency_value == null) {
if (counter < MAX_COUNTER) {
++counter;
CurrencyJsonDownloader cDownloader = new CurrencyJsonDownloader(
curr, holder.textView); //download currency value in background, and set textview text if currency_value has been loaded in onpostExcecute (i'm using AsyncTask)
String url = CURRENCY_URL.replace("<symbol>", curr.symbol);
Log.d(Constants.APP_TAG, "Url currency: " + url);
cDownloader.execute(url);
}
holder.textView.setText("");
} else {
holder.textView.setText(curr.currency_value);
}
holder.imgView.setImageResource(curr.drawableId);
return row;
}
#Override
public CurrencyModel getItem(int position) {
// TODO Auto-generated method stub
return adapter_models.get(position);
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return adapter_models.size();
}
}
static class CurrencyAdapterContainer {
ImageView imgView;
TextView textView;
}
and here is the output in my logcat
position : 0
APP NULL
position : 1
APP NOT NULL
position : 2
APP NOT NULL
position : 3
APP NOT NULL
.
.
.
position : 10
APP NOT NULL
which make a disaster because it means that the textview being passed in the background job is the same textview and the the changed view is the same textview and the other textview will have blank view unless i scroll it of course which call again the getView() and everything is fine. But it's a problem when starting the app, because just one textview that always changing its value.
so why is this happen? and is there any hack that i can do??
thanks before...
ListView item Views are recycled, so never hold a reference to a particular item view and expect it to represent same data after ListView has been scrolled.
Pass the data item to your worker task instead and let it update the data to it.
Updating:
If your current item is off screen, It'll be requested from adapter (
when ListView scroll to it), and will show updated data.
If that item is currently being displayed , call notifyDataSetChanged() on adapter, this will make ListView refresh its displayed items.
I think problem is with your List adapter. Here i had posted a adapter class i think it will help you.
public class UploadListAdaptor extends BaseAdapter {
private Context context;
private List<UploadDetailsObj> uploadList;
public UploadListAdaptor(Context context, List<UploadDetailsObj> list) {
this.context = context;
uploadList = list;
}
public int getCount() {
return uploadList.size();
}
public Object getItem(int position) {
return uploadList.get(position);
}
public long getItemId(int position) {
return position;
}
/** LIST CATEGORY */
public View getView(int position, View convertView, ViewGroup viewGroup) {
final UploadDetailsObj chlListObj = uploadList.get(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater
.inflate(R.layout.inflator_progress_bar, null);
TextView photoName = (TextView) convertView
.findViewById(R.id.tv_photoname);
Button btnProgress=(Button)convertView.findViewById(R.id.btn_progress);
photoName.setText(chlListObj.getPhotoName());
}
return convertView;
}
}
You can call this adapter by using this code.
List<UploadDetailsObj> listofUploads= new ArrayList<UploadDetailsObj>();
UploadListAdaptor uploadListAdptr = new UploadListAdaptor(yourclass.this,
listofUploads);
uploadListView.setAdapter(uploadListAdptr);

Consultation about painting row in mt ListView

How do I paint every value that under 100 in red in my ListView?
i have ListView that connect to my_list.xml
i connect the cursor like this:
public void update_list(String NN) {
c = db.rawQuery(NN, null);
startManagingCursor(c);
String[] from = new String[]{"_id","Store","Makat","Des","Qty" };
int[] to = new int[]{R.id.txtID, R.id.txtStore,R.id.txtMakat ,R.id.txtDes ,R.id.txtQty};
SimpleCursorAdapter notes = new SimpleCursorAdapter (this, R.layout.my_list, c, from, to);
setListAdapter(notes);
}
How to do it ?
My suggestion would be to make your own adapter which would extend SimpleCursorAdapter. In it, you should override the getView method which creates every row view.
class MyCustomAdapter extends SimpleCursorAdapter{
private Context context;
private Cursor c;
public MyCustomAdapter(Context context, int layout, Cursor c,
String[] from, int[] to) {
super(context, layout, c, from, to);
this.c = c;
this.context = context;
}
#Override
public View getView(int pos, View inView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.rowlayout, parent, false);
this.c.moveToPosition(pos);
//get the value from cursor, evaluate it, and set the color accordingly
int columnIndexOfQty = 4;
int qty = c.getInt(columnIndexOfQty);
if(qty < 100){
rowView.setBackgroundColor(Color.RED);
}
return rowView;
}
}
There may be some errors, but I think that you must get the idea.

Fetching images from SD Card and displaying in Gridview

I am attempting to fetch all the images from the SD Card and display them in a gridview (contained in a fragment). However, although no exceptions are thrown, nothing is displayed in the gridview, just a plain black screen. I'm not sure where the problem is, with the binding of the view or with the fetching of the data into the cursor. This is the current code for the fragment:
public class PhotoGridFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {
// member variables for
private static final int PHOTO_LIST_LOADER = 0x01;
private ImageCursorAdapter adapter;
private Cursor c;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getLoaderManager().initLoader(PHOTO_LIST_LOADER, null, this);
adapter = new ImageCursorAdapter(getActivity().getApplicationContext(), c);
}
/* R.layout.grid_item,
null, new String[] { MediaStore.Images.Thumbnails.DATA }, new int[] {R.id.grid_item},
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); */
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.photo_item, container, false);
}
// Loader manager methods
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
String[] projection = { MediaStore.Images.Thumbnails._ID, MediaStore.Images.Thumbnails.DATA };
CursorLoader cursorLoader = new CursorLoader(getActivity(),
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection,
null, null, null);
return cursorLoader;
}
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
adapter.swapCursor(cursor);
}
public void onLoaderReset(Loader<Cursor> cursor) {
adapter.swapCursor(null);
}
private class ImageCursorAdapter extends CursorAdapter {
private LayoutInflater mLayoutInflater;
private Context mContext;
public ImageCursorAdapter(Context context, Cursor c) {
super(context, c);
mContext = context;
mLayoutInflater = LayoutInflater.from(context);
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
ImageView newView = (ImageView) view.findViewById(R.layout.grid_item);
String imagePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID));
if (imagePath != null && imagePath.length() != 0 && newView != null) {
newView.setVisibility(ImageView.VISIBLE);
}
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View v = mLayoutInflater.inflate(R.layout.grid_item, parent, false);
return v;
}
}
The layout files for the project are as follows:
photo_item.xml:
<?xml version="1.0" encoding="UTF-8"?>
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/photo_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="24dp"
android:padding="6dp" />
grid_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/grid_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="24dp"
android:padding="6dp"
/>
in bindView, you're not actually setting the imageView's drawable to anything. You grab an image path, verify it's a real path, and then ignore it :) Use the path to get a drawable! Then set the imageView's drawable to that image.
Try this code
sdcard.java
public class Sdcard extends Activity {
// Cursor used to access the results from querying for images on the SD card.
private Cursor cursor;
// Column index for the Thumbnails Image IDs.
private int columnIndex;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sdcard);
// Set up an array of the Thumbnail Image ID column we want
String[] projection = {MediaStore.Images.Thumbnails._ID};
// Create the cursor pointing to the SDCard
cursor = managedQuery( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
projection, // Which columns to return
null, // Return all rows
null,
MediaStore.Images.Thumbnails.IMAGE_ID);
// Get the column index of the Thumbnails Image ID
columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);
GridView sdcardImages = (GridView) findViewById(R.id.gridView1);
sdcardImages.setAdapter(new ImageAdapter(this));
}
private class ImageAdapter extends BaseAdapter {
private Context context;
public ImageAdapter(Context localContext) {
context = localContext;
}
public int getCount() {
return cursor.getCount();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView picturesView;
if (convertView == null) {
picturesView = new ImageView(context);
// Move cursor to current position
cursor.moveToPosition(position);
// Get the current value for the requested column
int imageID = cursor.getInt(columnIndex);
// Set the content of the image based on the provided URI
picturesView.setImageURI(Uri.withAppendedPath(
MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, "" + imageID));
picturesView.setScaleType(ImageView.ScaleType.FIT_XY);
picturesView.setPadding(10, 10, 10, 10);
picturesView.setLayoutParams(new GridView.LayoutParams(100, 100));
}
else {
picturesView = (ImageView)convertView;
}
return picturesView;
}
}
}

Categories