NullPointer Exception on android image gallery onselected
<p>I am using android image gallery,I want to select image tag id by click on gallery item and put that id in to <code>HashMap</code> (param_ids). I used the following code.but this gave me a <code>NullPointerException</code> on this line before I clicked on gallery item.</p>

<pre><code>  param_ids.put("facial_appearance_id",view.getTag().toString());
</code></pre>

<p>this will working fine on <code>android 2.3</code> but this will give an <code>NullPointerException</code> on <code>android 4.0.3</code>. so how can I slove this issue?</p>

<p>code</p>

<pre><code>Gallery faceGallery= (Gallery) findViewById(R.id.gallery);
faceGallery.setOnItemSelectedListener(new OnItemSelectedListener() {

@Override
public void onItemSelected(AdapterView&lt;?&gt; parent, View view,int position, long id) {
    param_ids.put("facial_appearance_id",view.getTag().toString());
            }
@Override
public void onNothingSelected(AdapterView&lt;?&gt; parent) {
// TODO Auto-generated method stub

        }
 });
</code></pre>
