final String[] ContactsFliter = {Contacts.DISPLAY_NAME, BaseColumns._ID};
Cursor c = getContentResolver().query(Contacts.CONTENT_URI, ContactsFliter, null, null, null);
startManagingCursor(c);ListAdapter adapter = new SimpleCursorAdapter(this,
         android.R.layout.simple_list_item_2,
         c, ContactsFliter,
         new int[]{android.R.id.text1, android.R.id.text2});
 m_ListView.setAdapter(adapter);
m_ListView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){ @Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
//请问,这里的arg3是什么东西?
}问题在上面的注释里面,据文档介绍,arg3参数是:The row id of the item that is selected,但上面的例子中,arg3的值居然是数据库里面的BaseColumns._ID的值!百思不得其解。
注:我看的是2.2文档,但用的是2.1 API开发的。

解决方案 »

  1.   

    BaseColumns 
    String _ID The unique ID for a row. The row id of the item that is selected
    应该是说的同一个ID吧。
      

  2.   

    public abstract void onItemSelected (AdapterView<?> parent, View view, int position, long id) 
    Since: API Level 1 Callback method to be invoked when an item in this view has been selected. Impelmenters can call getItemAtPosition(position) if they need to access the data associated with the selected item.Parameters
    parent  The AdapterView where the selection happened 
    view  The view within the AdapterView that was clicked 
    position  The position of the view in the adapter 
    id  The row id of the item that is selected  
      

  3.   

    回二三楼,我觉得不一样,比如我把
    final String[] ContactsFliter = {Contacts.DISPLAY_NAME, BaseColumns._ID};
    改为
    final String[] ContactsFliter = {Contacts.DISPLAY_NAME, Contacts.HAS_PHONE_NUMBER};
    你觉得会怎样呢?
      

  4.   

    是pisition,就是第几个item吧。arg0是选的item,是个view对象。arg1是item的id号,从0开始,跟数组的id号类似。arg3就是item的位置。不知道准不准确。arg3一直没怎么用。你可以log输出看看,我觉得你之所以输出的是BaseColumns._ID的值,是因为arg3是从1开始的,你如果查的全表,那么他们的值就是相等的。你可以
    log.e(TAG,"arg3 is"+(arg3+1));
    log.e(TAG,"BaseColumns._ID is"+BaseColumns._ID);
    看看是不是有区别
      

  5.   

    回楼上,我对Sql语句做了排序,做了条件判断,无论怎样,arg3的值都等于数据库中BaseColumns._ID的值。
      

  6.   

    另外想问一下,如果不使用arg3,我如何得到BaseColumns._ID的值呢?
      

  7.   

    打印了一下,arg2和arg3的值貌似一样的
      

  8.   

    我用的ARG2和ARG3的值不一样,ARG2从0开始,ARG3是1,3,5这样递增的数不知道为什么