Android context menu's info.position changing with orientation change
<p>My activity is a ListActivity populated by an <code>ArrayList&lt;HashMap&lt;String,String&gt;&gt; THREADS;</code> </p>

<p>I've also defined an <code>ArrayList&lt;ArrayList&lt;HashMap&lt;String,String&gt;&gt;&gt; PAGES;</code> that is populated in the getView of my activity.</p>

<p>For each THREADS item, I add corresponding data to PAGES</p>

<pre><code>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&amp;page=PAGE_NUMBER_HERE");
                      int p = Integer.parseInt(lp);
                      ArrayList&lt;HashMap&lt;String, String&gt;&gt; lnks = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();

                          for(int u=0;u&lt;p;u++){
                              HashMap&lt;String,String&gt; temp = new HashMap&lt;String,String&gt;();
                              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);

                          }
...
}
</code></pre>

<p>This PAGES ArrayList is accessed through a context menu</p>

<pre><code>           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&lt;?&gt; 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;
</code></pre>

<p>This context menu also accesses the THREADS ArrayList</p>

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

<p>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.  </p>
