title: ListView always returns the first position
body: <p>I'm doing an app to help me at school. But, I have a problem: when I want the position (int position) of the listView, it ALWAYS returns the first position, even if I select the third position, for example. </p>
  
  <pre><code>public class TestsActivity extends ListActivity implements AdapterView.OnItemClickListener, DialogInterface.OnClickListener {
      private List&lt;Map&lt;String, Object&gt;&gt; tests;
      private AlertDialog dialogDelete;
      private int selectedTest;
      private Application dao;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.tests_activity);
  
          dao = new Application(this);
  
          android.app.ActionBar actionBar = getActionBar();
          actionBar.setTitle("My tests");
  
          actionBar.setHomeButtonEnabled(true);
          actionBar.setDisplayHomeAsUpEnabled(true);
  
          String[] from = {"subject", "content"};
          int[] to = {R.id.subject, R.id.content};
  
          SimpleAdapter adapter = new SimpleAdapter(this, listTests(), R.layout.test_list_activity, from, to);
          setListAdapter(adapter);
          getListView().setOnItemClickListener(this);
  
          registerForContextMenu(getListView());
  
          this.dialogDelete = createDialogDelete();
      }
  
      private List&lt;Map&lt;String, Object&gt;&gt; listTests() {
  
          tests = new ArrayList&lt;Map&lt;String, Object&gt;&gt;();
  
          List&lt;Test&gt; TestList = dao.listTests();
  
          for (Test test : TestList) {
  
              Map&lt;String, Object&gt; item = new HashMap&lt;String, Object&gt;();
  
              Long id = test.getId();
              String subject = test.getSubject();
  
              item.put("id", test.getId());
  
              item.put("subject", subject);
  
              test.add(item);
          }
  
          return tests;
      }
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
          Map&lt;String, Object&gt; map = tests.get(position);
  
          String subject = (String) map.get("subject");
          String msg = "Test of" + subject;
  
          Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
  
          selectedTest = position;
  
      }
  
      @Override
      public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
          MenuInflater inflater = getMenuInflater();
          inflater.inflate(R.menu.tests_context_menu, menu);
      }
  
      public boolean onContextItemSelected(MenuItem item) {
  
          Intent intent;
          String id = String.valueOf(tests.get(selectedTest).get("id"));
  
          switch (item.getItemId()) {
  
              case R.id.remove:
                  dialogDelete.show();
                  break;
  
              case R.id.edit:
                  intent = new Intent(this, NewTestActivity.class);
                  intent.putExtra(Constantes.TEST_ID, id);
                  startActivity(intent);
                  return true;
          }
  
          return super.onContextItemSelected(item);
      }
  
      @Override
      public void onClick(DialogInterface dialog, int item) {
          Intent intent;
          String id = String.valueOf(tests.get(selectedTest).get("id"));
  
          switch (item) {
              case DialogInterface.BUTTON_POSITIVE:
                  tests.remove(selectedTest);
                  dao.removeTest(id);
                  getListView().invalidateViews();
                  break;
  
              case DialogInterface.BUTTON_NEGATIVE:
                  dialogDelete.dismiss();
                  break;
          }
      }
  
      private AlertDialog createDialogDelete() {
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
  
          builder.setMessage(R.string.confirm_delete_test);
  
          builder.setPositiveButton(getString(R.string.yes), (android.content.DialogInterface.OnClickListener) this);
          builder.setNegativeButton(getString(R.string.no), (android.content.DialogInterface.OnClickListener) this);
  
          return builder.create();
      }
  
      @Override
      protected void onDestroy() {
          dao.close();
          super.onDestroy();
      }
  }
  </code></pre>
  
  <p>How can I solve it?</p>