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开发的。
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开发的。
解决方案 »
- android系统横竖屏切换问题
- Android 开机自启动程序问题
- ContentResolver的query和SQLiteDatabase的query
- eclipse + android x86调试全过程,欢迎大家拍砖
- [Android ] EditText 自定软键盘弹出问题
- 聊天工具发表情在android上具体怎么实现的
- ListView Item 改变 控件属性的问题
- SNE平台与Android平台有什么区别?
- 模拟器显示Unfortunately,项目名has stoppped
- 问gallery的子项选择前和选择后的背景颜色改变,如何实现?
- emulator-5554 disconnected! Cancelling '解决?
- 调试Android时出现ActivityManager: Starting: Intent { act=android.intent.action.MAIN c
String _ID The unique ID for a row. The row id of the item that is selected
应该是说的同一个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
final String[] ContactsFliter = {Contacts.DISPLAY_NAME, BaseColumns._ID};
改为
final String[] ContactsFliter = {Contacts.DISPLAY_NAME, Contacts.HAS_PHONE_NUMBER};
你觉得会怎样呢?
log.e(TAG,"arg3 is"+(arg3+1));
log.e(TAG,"BaseColumns._ID is"+BaseColumns._ID);
看看是不是有区别