Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6336405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:03:00+00:00 2026-05-24T19:03:00+00:00

I am using this to get a list of elements from a webpage. http://www.gamespy.com/index/release.html

  • 0

I am using this to get a list of elements from a webpage.
http://www.gamespy.com/index/release.html

// Get all the game elements
Elements games = doc.select("div.FP_Up_TextWrap b");

 // Create new ArrayList
ArrayList<String> gameList = new ArrayList<String>();

// Iterator over those elements
ListIterator<Element> postIt = games.listIterator();

while (postIt.hasNext()) {
// Add the game text to the ArrayList
gameList.add(postIt.next().text());
}

This returns all the tags with which is what I want. But it returns the full tag with the title I just want the title the release date and a Img sr.
I would like to return it to a list view.
How would I go about doing this? I maybe doing it totally wrong so you guys may want to check out the HTML page source.

EDIT – Gives me NullPointer error

  /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    outputTextView = (TextView)findViewById(R.id.outputTextView);

   ListView list = (ListView)findViewById(R.id.list);
   ArrayList<String> gameList = new ArrayList<String>();


      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 > td.indexList1, tr > td.indexList2");
        // Iterator over those elements     
        ListIterator<Element> postIt = games.listIterator();          
        while (postIt.hasNext()) {     
             // Add the game text to the ArrayList     
             gameList.add(postIt.next().text());     
        }         

        String[] items = new String[gameList.size()];
        gameList.toArray(items);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, items);

    //  error points here    
             list.setAdapter(adapter);
    }


    }

EDIT – Layout for the list

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:id="@+id/outputTextView"
/>
<ListView    android:layout_height="wrap_content" android:id="@+id/list" android:layout_width="match_parent"></ListView>
</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:03:01+00:00Added an answer on May 24, 2026 at 7:03 pm

    You won’t be able to “return a list view” using this code, but you could create your own list view sub class which you could then return, following the same techniques:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        ListView listView1 = (ListView) findViewById(R.id.listView1);
    
        ArrayList<String> gameList = new ArrayList<String>();
    
        // Iterator over those elements     
        ListIterator<Element> postIt = games.listIterator();          
        while (postIt.hasNext()) {     
             // Add the game text to the ArrayList     
             gameList.add(postIt.next().text());     
        }         
    
        String[] items = new String[gameList.size()];
        gameList.toArray(items);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.some_list_item_view, items);
    
        listView1.setAdapter(adapter);
    }
    

    Ultimately what it comes down to is setting the list adapter for the list. If you need to create your own list adapter you can subclass and implement ListAdapter to databind other object types, but there’s already a predefined adapter (ArrayAdapter) for handling simple string sets for ListView/ListActivity databinding.

    UPDATE – Poster requested additional implementation details:

    Given:

    public class GameMeta {
        private String m_title;
        private java.util.Date m_releaseDate;
    
        public GameMeta() {
        }
    
        public String getTitle(){
             return m_title;
        }
    
        public void setTitle(String value) {
             m_title = value;
        }
    
        public java.util.Date getReleaseDate(){
             return m_releaseDate;
        }
    
        public void setReleaseDate(java.util.Date releaseDate){
             m_releaseDate = releaseDate;
        }
    }
    

    You might create the adapter:

    public class GamesMetaAdapter implements Adapter extends ListAdapter {
         private ArrayList<GameMeta> m_list = new ArrayList<GameMeta>();
         private Context m_context = null;
    
         public GamesMetaAdapter(Context context) {
             m_context = context;
         }
    
         @Override
         public int getCount(){
              return m_list.size();
         }
    
         @Override
         public Object getItem(int position){
            if(position < m_list.size()){
              return m_list.getAt(position);
            }
            return null;
         }
    
         @Override
         public long getItemId(int position) {
            return (long)position;
         }
    
         @Override
         public int getItemViewType(int position) {
            return IGNORE_ITEM_VIEW_TYPE;
         }
    
         @Override
         public View getView (int position, View convertView, ViewGroup parent) {
                 TextView simpleView = new TextView(this.m_context);
                 String viewText = this.m_items[position].getTitle() + ", Released " + this.m_items[position].getReleaseDate().toString();
    
                 simpleView.setText(this.m_items[position].getTitle());
    
                 if(TextView.class.isInstance(convertView)) {
                       convertView = simpleView;
                 }
    
                 return simpleView;
         }
    
    
         @Override
         public int getViewTypeCount() {
            return 1;
         }
    
         @Override
         public boolean hasStableIds(){
            return false;
         }
    
         @Override
         public boolean isEmpty() {
            return m_list.size() == 0;
         }
    
         @Override
         public void registerDataSetObserver (DataSetObserver observer) {
    
         }
    
         @Override
         public void unregisterDataSetObserver (DataSetObserver observer) {
    
         }
    
         /* LIST ADAPTER MEMBERS */
         @Override
         public boolean areAllItemsEnabled() {
              return true;
         }
    
         @Override
         public boolean isEnabled(int position) {
            return true;
         }    
    }
    

    I don’t have a Java compiler here, so please don’t ding me if this doesn’t just copy/paste right into your project, but it should be well north of 90% there.

    Happy coding.

    B

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using this PHP to get a list of Title's from an RSS feed:
I am trying to get Update queries from a list of files using this
I'm using this query to get all employees of {clients with name starting with
I have a list of elements and I wish to update them: from this:
I am using this to get items from this website and return to a
Im using this regex to get the contents of a tag in a file.
I am using this code to get the background image of a div .
I'm using this line to get the beginning time of the first day of
I'm making call to Alfresco Webscripts which return JSON. I do this using GET
Using this jquery code: <a href=javascript:void(0) id=m1>Get Selected id's</a> jQuery(#m1).click( function() { var s;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.