0

I've been searching and searching for answers and tutorials but I can't find one. So here's my problem.. I am a newbie in android and web development. I want to create an android app for my website. I want to fetch image and text from my website using json and make it as a listview in android (See photo below). I know now how to create xml's for the android. The problem is what I will do in the java code and php code for the images and texts to be retrieve. I find some tutorials but they didn't really have the solutions because they all retrieve the image from the res/drawable. I want to retrieve mine from the server of my database like http//example.com/example.php Another thing is to make it clickable so when I click it, it will go to another xml/activity. I hope to find good tutorials for this.

Image is as such

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
uhani_user
  • 1
  • 1
  • 5
  • http://www.learn2crack.com/2013/11/listview-from-json-example.html – Kamlesh Arya Feb 17 '14 at 09:41
  • have a look at this http://stackoverflow.com/questions/541966/how-do-i-do-a-lazy-load-of-images-in-listview – WISHY Feb 17 '14 at 09:42
  • @KamleshArya thanks but it the tutorial link is for populating listview with texts only. – uhani_user Feb 17 '14 at 13:46
  • @uhani_user create layout consisting of ImageView and TextView in it.anyway here is another link for more help http://www.androidbegin.com/tutorial/android-json-parse-images-and-texts-tutorial/ – Kamlesh Arya Feb 17 '14 at 14:21
  • @KamleshArya i know how to make layout for the imageview and textview. The problem is the fetching code itself for the php and java. – uhani_user Feb 17 '14 at 14:24

1 Answers1

0

For manage your json you could create a JsonAdapter, and for display remote image read this post

Or, if you send the image inside the json in some format (base64?) you have to handle it like bytearray reference

Community
  • 1
  • 1
Manuel Spigolon
  • 11,003
  • 5
  • 50
  • 73
  • My problem here is that i want to retrieve the images for example in http://localhost/example/images.. in your tutorials i get how to retrieve the texts but not the images.. The tutorial for images are not exactly what i'm looking for. But thanks anyway. The links are informative :) – uhani_user Feb 17 '14 at 14:03
  • if your php service (http//example.com/example.php) accept in input an id that you use for extract a blob from your database you could use HTTP header for put out an image. For example: http//example.com/example.php?id=4 and then in PHP [create an output image](http://www.php.net/manual/en/function.imagegif.php) – Manuel Spigolon Feb 17 '14 at 14:10
  • that i can see in all tutorials.. putting the specific HTTP header of the image in the java code. What if I have like 10 images to retrieve.. What header I will use? – uhani_user Feb 17 '14 at 14:18
  • you should make an HTTP call for each image at the url, and if you have a listview is quite simple: each row call the getView method, anche in each row you have an image object that you could inflate myImageView.setImageURI(Uri.parse("http://example.com/example.php?id="+ currentLineId)); this solution is not secure, but it is the simplest. For security you should create an AsynkTask that make an HTTP post with some user-key an then output the image like the link above: 'BitmapFactory.decodeByteArray(**byteArrayReadFromAsynkTask**, 0, imageTile.length);' – Manuel Spigolon Feb 17 '14 at 14:37