Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What it's doing is getting each HTML <code>&lt;td&gt;</code> (table cell) as a separate String as opposed to each <code>&lt;tr&gt;</code>. You probably already know this.</p> <p>You probably want to make a custom adapter that takes in multiple Strings (a couple elements from your List), and has an overrided <code>getView()</code> to display the contents exactly however you want them (lined up as if in a table, or in two-line format, with bigger text showing the game name, and smaller text saying "Platform: X Genre: Y Release Date: Z", for two examples).</p> <p><a href="http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/" rel="nofollow">Here is a tutorial on making your own custom list adapter</a> (this is as opposed to your current <code>ArrayAdapter&lt;String&gt;</code>).</p> <p>Let's have an object, <code>GameRelease</code>, for each item (what you probably want in place of Orders in the tutorial):</p> <pre><code>public class GameRelease { private String name; private String platform; private String genre; private String releaseDate; public String getName() { return name; } public String getPlatform() { return platform; } public String getReleaseDate() { return releaseDate; } public String getGenre() { return genre; } public GameRelease(String name, String platform, String genre, String releaseDate) { this.name = name; this.platform = platform; this.genre = genre; this.releaseDate = releaseDate; } } </code></pre> <p>Then, I would write an adapter that looks something like this, taking your new GameRelease object:</p> <pre><code>private class GameReleaseAdapter extends ArrayAdapter&lt;GameRelease&gt; { private ArrayList&lt;GameRelease&gt; items; public GameReleaseAdapter(Context context, ArrayList&lt;Order&gt; items) { // TODO: make a layout for each item which you'd call (for example) itemLayout super(context, R.layout.itemLayout, items); this.items = items; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO: return an item view styled however you want or as shown in the tutorial } } </code></pre> <p>Now once you have that all set, you can instead of your while loop adding only one String element per <code>&lt;td&gt;</code>, take the GameRelease and fill it with multiple <code>&lt;td&gt;</code> elements (four, in the same order the site gives them), ex:</p> <pre><code>ArrayList&lt;GameRelease&gt; gameList = new ArrayList&lt;GameRelease&gt;(); Document doc = null; try { doc = Jsoup.connect("http://www.gamespy.com/index/release.html").get(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Get all td's that are a child of a row - each game has 4 of these Elements games = doc.select("tr &gt; td.indexList1, tr &gt; td.indexList2"); // Iterator over those elements ListIterator&lt;Element&gt; postIt = games.listIterator(); while (postIt.hasNext()) { // Add the game text to the ArrayList String name = postIt.next().text(); String platform = postIt.next().text(); String genre = postIt.next().text(); String releaseDate = postIt.next().text(); gameList.add(new GameRelease(name, platform, genre, releaseDate)); Log.v(TAG, games.text()); } this.setListAdapter(new GameReleaseAdapter(this, gameList)); </code></pre> <p>Just a note: since <code>ArrayAdapter&lt;T&gt;</code> has a constructor for <code>List&lt;T&gt;</code> (instead of <code>T[]</code>), which is a superclass of <code>ArrayList&lt;T&gt;</code>, you can pass in your <code>ArrayList&lt;String&gt;</code> or <code>ArrayList&lt;GameRelease&gt;</code> instead of converting it into an array.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload