title: How to resolve error "cannot resolve method getItemAtPosition(int)".
body: <p>My code is that when i select an item on list, the item name should pass as toolbar for next screen.</p>
  
  <p>So while I'm passing the selected item by calling function putExtra(), in that I'm getting error on getItemAtPosition(i) like "cannot resolve method getItemAtPosition(int) </p>
  
  <p>here is my code... </p>
  
  <p>package com.example.hp.shapes;</p>
  
  <pre><code>import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.support.v7.widget.Toolbar;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  
  public class secondActivity extends AppCompatActivity {
  
      Toolbar mtoolbar;
      ListView l;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_second);
  
          mtoolbar=(Toolbar) findViewById(R.id.toolbar2);
  
          Bundle bundle=getIntent().getExtras();
          if(bundle!=null)
          {
              mtoolbar.setTitle(bundle.getString("shapeName"));
              if(mtoolbar.getTitle().toString().equalsIgnoreCase("Square"))
              {
                  l=(ListView) findViewById(R.id.listView2);
                  ArrayAdapter&lt;String&gt; m1=new ArrayAdapter&lt;String&gt;(secondActivity.this,
                          android.R.layout.simple_list_item_1,
                          getResources().getStringArray(R.array.square));
  
                 /* l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l)*/
  
  
   l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                 @Override
                 public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                     Intent intent1=new Intent(secondActivity.this,ThirdActivity.class);
                     intent1.putExtra("squareName", intent1.getItemAtPosition(i).toString());
                     startActivity(intent1);
  
                 }
             });
              l.setAdapter(m1);
  
  
          }
              else if(mtoolbar.getTitle().toString().equalsIgnoreCase("rectangle"))
              {
                  l=(ListView) findViewById(R.id.listView2);
                  ArrayAdapter&lt;String&gt; m1=new ArrayAdapter&lt;String&gt;(secondActivity.this,
                          android.R.layout.simple_list_item_1,
                          getResources().getStringArray(R.array.rectangle));
  
                  l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                          Intent i1=new Intent(secondActivity.this,ThirdActivity.class);
                          i1.putExtra("rectangleName",l.getItemAtPosition(i).toString());
                          startActivity(i1);
                      }
                  });
                  l.setAdapter(m1);
  
              }
              else if(mtoolbar.getTitle().toString().equalsIgnoreCase("parallelogram"))
              {
                  l=(ListView) findViewById(R.id.listView2);
                  ArrayAdapter&lt;String&gt; m1=new ArrayAdapter&lt;String&gt;(secondActivity.this,
                          android.R.layout.simple_list_item_1,
                          getResources().getStringArray(R.array.parallelogram));
  
                  l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                          Intent i1=new Intent(secondActivity.this,ThirdActivity.class);
                          i1.putExtra("Name1",l.getItemAtPosition(i).toString());
                          startActivity(i1);
                      }
                  });
                  l.setAdapter(m1);
  
              }
              else if(mtoolbar.getTitle().toString().equalsIgnoreCase("hexagon"))
              {
                  l=(ListView) findViewById(R.id.listView2);
                  ArrayAdapter&lt;String&gt; m1=new ArrayAdapter&lt;String&gt;(secondActivity.this,
                          android.R.layout.simple_list_item_1,
                          getResources().getStringArray(R.array.hexagon));
  
                  l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                          Intent i1=new Intent(secondActivity.this,ThirdActivity.class);
                          i1.putExtra("Name1",l.getItemAtPosition(i).toString());
                          startActivity(i1);
                      }
                  });
                  l.setAdapter(m1);
  
              }
              else if(mtoolbar.getTitle().toString().equalsIgnoreCase("octagon"))
              {
                  l=(ListView) findViewById(R.id.listView2);
                  ArrayAdapter&lt;String&gt; m1=new ArrayAdapter&lt;String&gt;(secondActivity.this,
                          android.R.layout.simple_list_item_1,
                          getResources().getStringArray(R.array.octagon));
  
                  l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                          Intent i1=new Intent(secondActivity.this,ThirdActivity.class);
                          i1.putExtra("Name1",l.getItemAtPosition(i).toString());
                          startActivity(i1);
                      }
                  });
                  l.setAdapter(m1);
  
              }
              else if(mtoolbar.getTitle().toString().equalsIgnoreCase("pentagon"))
              {
                  l=(ListView) findViewById(R.id.listView2);
                  ArrayAdapter&lt;String&gt; m1=new ArrayAdapter&lt;String&gt;(secondActivity.this,
                          android.R.layout.simple_list_item_1,
                          getResources().getStringArray(R.array.pentagon));
  
                  l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                          Intent i1=new Intent(secondActivity.this,ThirdActivity.class);
                          i1.putExtra("Name1",l.getItemAtPosition(i).toString());
                          startActivity(i1);
                      }
                  });
                  l.setAdapter(m1);
  
              }
              else if(mtoolbar.getTitle().toString().equalsIgnoreCase("cube"))
              {
                  l=(ListView) findViewById(R.id.listView2);
                  ArrayAdapter&lt;String&gt; m1=new ArrayAdapter&lt;String&gt;(secondActivity.this,
                          android.R.layout.simple_list_item_1,
                          getResources().getStringArray(R.array.cube));
  
                  l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                          Intent i1=new Intent(secondActivity.this,ThirdActivity.class);
                          i1.putExtra("Name1",l.getItemAtPosition(i).toString());
                          startActivity(i1);
                      }
                  });
                  l.setAdapter(m1);
  
              }
          }
      }
  }
  </code></pre>