title: ListView cannot be resolved
body: <p>Everybody. I'm having a trouble with this excerpt from this code:</p>
  
  <pre><code>cocktailListView.setAdapter(adapter);
  </code></pre>
  
  <p>cocktailListView cannot be resolved</p>
  
  <p>My entire code is:</p>
  
  <pre><code>public class SearchCustomListViewActivity extends ListActivity {
      //ArrayList thats going to hold the search results
      ArrayList&lt;HashMap&lt;String, Object&gt;&gt; searchResults;
  
      //ArrayList that will hold the original Data
      ArrayList&lt;HashMap&lt;String, Object&gt;&gt; originalValues;
      LayoutInflater inflater;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.main);
          final EditText searchBox=(EditText) findViewById(R.id.searchBox);
          ListView playerListView=(ListView) findViewById(android.R.id.list);
  
          //get the LayoutInflater for inflating the customomView
          //this will be used in the custom adapter
          inflater=(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
          //these arrays are just the data that
          //I'll be using to populate the ArrayList
          //You can use our own methods to get the data
          String names[]={"Ronaldo","Messi","Torres","Iniesta",
                  "Drogba","Gerrard","Rooney","Xavi"};
  
          String teams[]={"Real Madrid","Barcelona","Chelsea",
                  "Barcelona","Chelsea","Liverpool",
                  "ManU","Barcelona"};
          Integer[] photos={R.drawable.amazonas,R.drawable.amazonas,
                  R.drawable.amazonas,R.drawable.amazonas,
                  R.drawable.amazonas,R.drawable.amazonas,
                  R.drawable.amazonas,R.drawable.amazonas};
  
          originalValues=new ArrayList&lt;HashMap&lt;String,Object&gt;&gt;();
  
          //temporary HashMap for populating the
          //Items in the ListView
          HashMap&lt;String , Object&gt; temp;
  
          //total number of rows in the ListView
          int noOfPlayers=names.length;
  
          //now populate the ArrayList players
          for(int i=0;i&lt;noOfPlayers;i++)
          {
              temp=new HashMap&lt;String, Object&gt;();
  
              temp.put("name", names[i]);
              temp.put("team", teams[i]);   
              temp.put("photo", photos[i]);
  
              //add the row to the ArrayList
              originalValues.add(temp);       
          }
          //searchResults=OriginalValues initially
          searchResults=new ArrayList&lt;HashMap&lt;String,Object&gt;&gt;(originalValues);
  
          //create the adapter
          //first param-the context
          //second param-the id of the layout file
          //you will be using to fill a row
          //third param-the set of values that
          //will populate the ListView
          final CustomAdapter adapter=new CustomAdapter(this, R.layout.players_layout,searchResults);
  
          //finally,set the adapter to the default ListView
          cocktailListView.setAdapter(adapter);
          searchBox.addTextChangedListener(new TextWatcher() {
              public void onTextChanged(CharSequence s, int start, int before, int count) {
                  //get the text in the EditText
                  String searchString=searchBox.getText().toString();
                  int textLength=searchString.length();
                  searchResults.clear();
  
                  for(int i=0;i&lt;originalValues.size();i++)
                  {
                      String playerName=originalValues.get(i).get("name").toString();
                      if(textLength&lt;=playerName.length()){
                          //compare the String in EditText with Names in the ArrayList
                          if(searchString.equalsIgnoreCase(playerName.substring(0,textLength)))
                              searchResults.add(originalValues.get(i));
                      }
                  }
  
                  adapter.notifyDataSetChanged();
              }
  
              public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
  
              public void afterTextChanged(Editable s) {}
          });
      }
  
      //define your custom adapter
      private class CustomAdapter extends ArrayAdapter&lt;HashMap&lt;String, Object&gt;&gt;
      {
          public CustomAdapter(Context context, int textViewResourceId,
                  ArrayList&lt;HashMap&lt;String, Object&gt;&gt; Strings) {
              //let android do the initializing :)
              super(context, textViewResourceId, Strings);
          }
  
          //class for caching the views in a row 
          private class ViewHolder
          {
              ImageView photo;
              TextView name,team;
          }
          ViewHolder viewHolder;
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              if(convertView==null)
              {
                  convertView=inflater.inflate(R.layout.players_layout, null);
                  viewHolder=new ViewHolder();
  
                  //cache the views
                  viewHolder.photo=(ImageView) convertView.findViewById(R.id.photo);
                  viewHolder.name=(TextView) convertView.findViewById(R.id.name);
                  viewHolder.team=(TextView) convertView.findViewById(R.id.team);
  
                  //link the cached views to the convertview
                  convertView.setTag(viewHolder);
              }
              else
                  viewHolder=(ViewHolder) convertView.getTag();
  
              int photoId=(Integer) searchResults.get(position).get("photo");
  
              //set the data to be displayed
              viewHolder.photo.setImageDrawable(getResources().getDrawable(photoId));
              viewHolder.name.setText(searchResults.get(position).get("name").toString());
              viewHolder.team.setText(searchResults.get(position).get("team").toString());
  
              //return the view to be displayed
              return convertView;
          }
      }
  }
  </code></pre>