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

  • Home
  • SEARCH
  • 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 6649029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:43:32+00:00 2026-05-26T00:43:32+00:00

My activity is a ListActivity populated by an ArrayList<HashMap<String,String>> THREADS; I’ve also defined an

  • 0

My activity is a ListActivity populated by an ArrayList<HashMap<String,String>> THREADS;

I’ve also defined an ArrayList<ArrayList<HashMap<String,String>>> PAGES; that is populated in the getView of my activity.

For each THREADS item, I add corresponding data to PAGES

public View getView(int position, View convertView, ViewGroup parent){
...
                      String lp = THREADS.get(position).get("lastPage");
                      String base = THREADS.get(position).get("base").replaceAll("^.*(?:td\\-p\\/)", "").replaceAll("/jump-to/first-unread-message", "?page_size=25&page=PAGE_NUMBER_HERE");
                      int p = Integer.parseInt(lp);
                      ArrayList<HashMap<String, String>> lnks = new ArrayList<HashMap<String, String>>();

                          for(int u=0;u<p;u++){
                              HashMap<String,String> temp = new HashMap<String,String>();
                              temp.put("page", Integer.toString(u+1));
                              temp.put("base", base);
                              temp.put("title", THREADS.get(position).get("title"));
                              lnks.add(temp);
                              PAGES.add(position, lnks);

                          }
...
}

This PAGES ArrayList is accessed through a context menu

           case R.id.goPage:
                final Dialog dlg = new Dialog(ThreadListing.this);
                dlg.setContentView(R.layout.link_selector);
                ListView sel = (ListView) dlg.findViewById(R.id.linksel);

                adaptr = new SimpleAdapter(this, PAGES.get(info.position), R.layout.link_sel_row, new String[]{"page"}, new int[]{R.id.link_title});
                pgs = PAGES.get(info.position);
                sel.setAdapter(adaptr);
                dlg.setTitle(PAGES.get(info.position).get(0).get("title"));

                dlg.show();
                sel.setOnItemClickListener(new OnItemClickListener(){
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id){
                        Intent i = new Intent(getApplicationContext(), ThreadViewer.class);
                        String pg = pgs.get(position).get("base").replaceAll("PAGE_NUMBER_HERE", pgs.get(position).get("page"));
                        i.setData(Uri.parse(pg));
                        startActivity(i);
                        dlg.dismiss();
                    }
                });
                return true;

This context menu also accesses the THREADS ArrayList

On first load of the activity, everything is matched up correctly. The dialog shows the correct title, and the adapter contains the correct data.

However, when I either start a new activity then return via the back button, or change the orientation, the dialog gets thrown out of order. It starts showing the title and adapter for a list item earlier than the one I am selecting as if info.position referred to a different position, however the context menu item that accesses THREADS remains in the correct order. So THREADS.get(info.position) and PAGES.get(info.position) aren’t synced anymore somehow. Changing the orientation again sometimes re-syncs it correctly, but I don’t understand how this happens in the first place.

  • 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-26T00:43:33+00:00Added an answer on May 26, 2026 at 12:43 am

    Why exactly are you adding to the PAGES ArrayList in GetView?

     for(int u=0;u<p;u++){
         ....
         PAGES.add(position, lnks);
     }
    

    getView doesn’t belong to the Activity it is (likely, but not certain without seeing your code) inherited from Adapter That method is intended to return a view corresponding to a row, not to modify the dataset as you are doing. When returning from another Activity or changing orientation the system is refreshing the views (by calling getView on the adapter) which is modifying the underlying dataset, which is obviously not what you intended.

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

Sidebar

Related Questions

I've populated a ListActivity from a Cursor using SimpleCursorAdapter that starts another activity when
I have an activity that has a TabHost containing a set of TabSpecs each
i have created a workflow activity that do give the item creater of a
Got an activity that extends ListActivity . The list is backed up by a
I have an activity that extends ListActivity and implementsOnScrollListener: public class RecentItemsList extends GenericListActivity
In my Mac OS X Activity monitor it lists each process id for each
I have a web-based application that notifies users of activity on the site via
Currently I have a class that is extending the ListActivity class. I need to
I have a Contact Activity which is derived from ListActivity, which displays list of
I have a layout that creates a ListActivity. Before displaying the ListActivity, I perform

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.