title: Variable 'adapter' is accessed from within inner class. Needs to be declared final
body: <p>Problems in variable 'adapter' and declaring final. My IDE keeps on telling 'adapter' needs to be declared as final, where and how to i do it?  This had made me come to a stand still i cant seem to move on from there. please help. Its in reference to this code here and problem: <a href="https://stackoverflow.com/questions/11920687/android-imageview-from-listview">Android ImageView from ListView</a></p>
  
  <pre><code>package com.example.androidhive;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  
  import android.content.Intent;
  import android.widget.TextView;
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ListView;
  
  
  public class CustomizedListView extends Activity {
      // All static variables
      static final String URL = "http://imforchange.org/international-movement-for-change/testing/data.xml";
  
      // XML node keys
      static final String KEY_EVENT = "event"; // parent node
      static final String KEY_ID = "eventId";
      static final String KEY_TITLE = "eventName";
      static final String KEY_DESCRIPTION = "eventDescription";
      static final String KEY_ABSTRACT = "eventAbstract";
      static final String KEY_DATE = "eventDate";
      static final String KEY_PRICE = "eventPrice";
      static final String KEY_LINK = "eventLink";
      static final String KEY_ADDRESS = "eventAddress";
      static final String KEY_CUSTOM_LINK = "eventCustomlink";
      static final String KEY_PICTURE = "eventPicture";
      static final String KEY_ICON = "eventIcon";
  
      ListView list;
      LazyAdapter adapter;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
  
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
          LazyAdapter  adapter = new LazyAdapter(this, songsList);
  
          XMLParser parser = new XMLParser();
          String xml = parser.getXmlFromUrl(URL); // getting XML from URL
          Document doc = parser.getDomElement(xml); // getting DOM element
  
          NodeList nl = doc.getElementsByTagName(KEY_EVENT);
          // looping through all song nodes &lt;song&gt;
          for (int i = 0; i &lt; nl.getLength(); i++) {
              // creating new HashMap
              HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
              Element e = (Element) nl.item(i);
              // adding each child node to HashMap key =&gt; value
              map.put(KEY_ID, parser.getValue(e, KEY_ID));
              map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
              map.put(KEY_DESCRIPTION, parser.getValue(e, KEY_DESCRIPTION));
              map.put(KEY_ABSTRACT, parser.getValue(e, KEY_ABSTRACT));
              map.put(KEY_DATE, parser.getValue(e, KEY_DATE));
              map.put(KEY_PRICE, parser.getValue(e, KEY_PRICE));
              map.put(KEY_LINK, parser.getValue(e, KEY_LINK));
              map.put(KEY_ADDRESS, parser.getValue(e, KEY_ADDRESS));
              //map.put(KEY_CUSTOM_LINK, parser.getValue(e, KEY_CUSTOM_LINK));
              map.put(KEY_PICTURE, parser.getValue(e, KEY_PICTURE));
              map.put(KEY_ICON, parser.getValue(e, KEY_ICON));
  
              // adding HashList to ArrayList
              songsList.add(map);
          }
  
  
          list=(ListView)findViewById(R.id.list);
  
          // Getting adapter by passing xml data ArrayList
          adapter=new LazyAdapter(this, songsList);
          list.setAdapter(adapter);
  
  
          // Click event for single list row
          list.setOnItemClickListener(new OnItemClickListener() {
  
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                      int position, long id) {
                      // Get the item that was clicked
  
                      HashMap&lt;String, String&gt; map = adapter.getItem(position); 
                      // Starting new intent
                      Intent in = new Intent(getApplicationContext(), DetailView.class);
                      in.putExtra(KEY_TITLE, map.get(KEY_TITLE));
                      in.putExtra(KEY_PICTURE, map.get(KEY_PICTURE)); 
                      in.putExtra(KEY_DESCRIPTION, map.get(KEY_DESCRIPTION));
                      in.putExtra(KEY_PRICE, map.get(KEY_PRICE));
                      in.putExtra(KEY_LINK, map.get(KEY_LINK));
                      startActivity(in);
                  }
          });     
      }
  }
  </code></pre>