I am creating an application in which I want to load images from the device gallery and call it ListView
.
I need a phased work code example
List of images from the gallery here Code to get -
Public Fixed Array List & lt; String & gt; GetImagesFromGallery (activity activity) {Uri uri; Cursor cursor; Int column_index_data, column_index_folder_name; ArrayList & LT; String & gt; List all images = new Arasuachi & lt; String & gt; (); String full pathoffimage = faucet; Uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI; String [] Projection = {MediaColumns.DATA, MediaStore.images.Media.BUCKET_DISPLAY_NAME}; Cursor = activity.getContentResolver (). Query (Yuri, projection, blank, empty, empty); Column_index_data = cursor.getColumnIndexOrThrow (Media column.DATA); Column_index_folder_name = Cursor GetColumnIndexOrThrow (MediaStore.Media.buyeT_DISPLAY_NAME); While (cursor.movetext ()) {absolutePathOfImage = cursor.getString (column_index_data); ListOfAllImages.add (absolutePathOfImage); } Return list all images; }
After that you can create a custom adapter class and display all the images.
Also remember one more thing to add to your app's manifest file -
Hope this will help you.
No comments:
Post a Comment