title: Android: how to get the clicked item position in the ListView?
body: <p>The code of my listview is like:</p>
  
  <pre><code>CourseDataAdapter mCourseListAdapter = new CourseDataAdapter(this, R.layout.coursesearchviewrow, mCursor);
  
  list.setAdapter(mCourseListAdapter);
  
  list.setItemsCanFocus(false);
  
  list.setOnItemClickListener(new OnItemClickListener() {
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1,
                              int arg2, long arg3) {
          long index = arg0.getSelectedItemId();
          listDialog.dismiss();
  
      }
  
  });
  </code></pre>
  
  <p>and I use my customized cursor adapter, my code is here:</p>
  
  <pre><code>public class CourseDataAdapter extends ResourceCursorAdapter {
      private TextView courseType;
      private TextView courseDays;
      private TextView courseTime;
  
      public CourseDataAdapter(Context context, int layout, Cursor c) {
          super(context, layout, c);
      }
  
      @Override
      public View newView(Context context, Cursor cursor, ViewGroup parent) {
          LayoutInflater mInflater = (LayoutInflater)context.getSystemService
                    (Context.LAYOUT_INFLATER_SERVICE);
          return mInflater.inflate(R.layout.coursesearchviewrow, parent, false);
      }
  
      @Override
      public void bindView(View view, Context context, Cursor cursor) {
          courseType = (TextView) view.findViewById(R.id.course_search_type_view);
          courseDays = (TextView) view.findViewById(R.id.course_search_days_view);
          courseTime = (TextView) view.findViewById(R.id.course_search_time_view);
  
          courseType.setText(cursor.getString(cursor.getColumnIndex(CourseDbAdapter.KEY_TYPE)));
          courseDays.setText(CourseDataHandler.daysStringProcessor(cursor.getInt(cursor.getColumnIndex(CourseDbAdapter.KEY_DAYS))));
          courseTime.setText(CourseDataHandler.courseTimeProcessor(cursor.getString(cursor.getColumnIndex(CourseDbAdapter.KEY_START_TIME)), cursor.getString(cursor.getColumnIndex(CourseDbAdapter.KEY_END_TIME))));
      }
  
  }
  </code></pre>
  
  <p>However, everytime when I clicked the item in the list, it the getSelectedItemId() method returns a invalid value.</p>
  
  <p>PS. I tried getSelectedItemPosition(), it also returns an invalid value, which is -1.</p>
  
  <p>So how can I get the Position of which item I clicked?</p>