Note that there are some explanatory texts on larger screens.

plurals
  1. PO(Hash-)Map has entry, get delivers null
    text
    copied!<p>I have no idea what is happening here. I have a HashMap with the following keyset of size 4:</p> <pre><code>steps.keySet() (java.util.HashMap$KeySet) [INIT_FZLIST, INIT_DATA, INSTALL_DATABASE, PROMPT_GERAETEID] </code></pre> <p>INIT_FZLIST, INIT_DATA, INSTALL_DATABASE and PROMPT_GERAETEID are values of an enum.</p> <p>Also the entrySet delivers the 4 entries.</p> <pre><code>steps.entrySet() (java.util.HashMap$EntrySet) [INIT_FZLIST=de.ansat.terminal.activity.widgets.PendingCheckbox{b50cb4e0 V.E..... ......I. 24,524-456,666}, INIT_DATA=de.ansat.terminal.activity.widgets.PendingCheckbox{b50c8748 V.E..... ......I. 24,350-456,524}, INSTALL_DATABASE=de.ansat.terminal.activity.widgets.PendingCheckbox{b508e288 V.E..... ......I. 24,68-456,209}, PROMPT_GERAETEID=de.ansat.terminal.activity.widgets.PendingCheckbox{b50c59b0 V.E..... ......I. 24,209-456,350}] </code></pre> <p>but if I do this:</p> <pre><code>steps.get(INSTALL_DATABASE) null </code></pre> <p>the map returns null and of cause I get a nullpointerexception if I try to work with the resulting object.</p> <p>This is running in an Android activity. I'm using Android 4.2.2 on API Level 17</p> <p>[Edit]</p> <pre><code>private Map&lt;InstallSteps, PendingCheckbox&gt; steps = new HashMap&lt;InstallSteps, PendingCheckbox&gt;(); </code></pre> <p>is a field of my activity class.</p> <p>I have several AsyncTasks working on that map, as it represents the progress of an installation process.</p> <p>PendingCheckbox is a View extending LinearLayout.</p> <p>[Edit2] steps is filled in onCreate(..) this way:</p> <pre><code> PendingCheckbox installDb = new PendingCheckbox(InstallActivity.this); installDb.setText(INSTALL_DATABASE); installDb.setChecked(false); installDb.setLayoutParams(layoutParams); root.addView(installDb); steps.put(InstallSteps.INSTALL_DATABASE, installDb); </code></pre> <p>Has anyone an idea what might cause this behaviour? I'm completly stuck. Any tip would be appreciated!</p>
 

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