Dorian Dorian - 22 days ago 6
Android Question

Android Image URL to table row

I would like to dynamically add some images from this page to the rows from my table.

This is my code so far:

TableLayout tableView = (TableLayout) findViewById(R.id.tableView);
TableRow row = new TableRow(this);
ImageView im;
im = new ImageView(this);
im.setImageResource(R.drawable.rss);
row.addView(im, new TableRow.LayoutParams(50, 50));
tableView.addView(row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));


Now... how can I make, for example, the image with the man with sunglasses, to be part of my table row?

PS: I would like my application to fetch each day the images, without me changing the code. That website updates one day to another, changing the news and the images.

Answer

Do you have an API from golfnews?

My norwegian is a bit rusty to be honest. So I can't really search around on the page.

Do you have any code for fetching the news? Or just one row in a tableview with an rss button? More or less.

You have as I see it three options, either use their api if they have one. You probably need to talk to them.

  1. Use the API, should give you image in base64 or similar if they have one.

  2. Use the RSS feed to fetch an index of the news and then parse each page and download the image in a temporary folder.

  3. Parse the homepage of golfnews.no and download the different pictures/cache them on the device.

For parsing homepages check the answers to this question: Parse HTML in Android