android - how to populate a ListView with images from camera -


I am able to populate the list item with the URI images from my camera. I can display the exact images as a list item.

The following is a list view that I am using (list item is a text view). I want to do the same thing with an image.

  ListView listview; ArrayList & LT; String & gt; List = New Arrestist & lt; String & gt; (); Private file getOutputMediaFile () {file mediaStorageDir = new file (imgLink); If (MediaStorageDir.exists ()) {if (! MediaStorageDir.mkdirs ()) {Log D. ("MyCameraApp", "The directory has failed to create"); Return tap; }} // Create a Media File Name String Timestamp = New SimpleDateform ("yyyyMMdd_HHmmss"). Format (new date ()); File media file; Mediafile = new file (mediaStorageDir.getPath () + file. Separator + "IMG _" + timestamp + ".jpg");} Chitrutut (byte [] data, camera camera) on public zune {file image file = getOutputMediaFile (); If (picturefile == empty) {log d. (Tag, "error in creating media file, check storage permissions"); Return; } {FileOutputStream fos = try New FileOutputStream (pictureFile); Fos.write (data); Fos.close (); } Hold (FileNotFoundException e) {Log D. (Tag, "File not found:" + e.getMessage ()); } Grip (IOE EXPRESS E) {Log D. (Tag, "Error accessing file:" + E. Message ()); } If (list.contains (pictureFile.toString ())} {System.out.println (image file + "-> already exists"); } Else {list.add (pictureFile.toString ()); System.out.println (picturefile + "added"); } PolulateList ();} Public Zero polulateList () {ArrayAdapter & lt; String & gt; ListAdapter = New array adapter & lt; String & gt; (This, R.Let.list_item, list); Listview.setAdapter (listAdapter); } 

When you insert items into the list, just call listAdapter. NotifyDataSetChanged ();

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -