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开发的。
解决方案 »
- fedora17 下 android 模拟器加载sencha-touch2 框架
- 采用子线程去操作进度条,ProgressBar 关闭不了----100分,在线等答案...
- 线程问题
- PhoneGap Connection用法求解
- Android 怎么点击一个按钮就连接到它的相册数据库上
- 那位给点android读取文件夹及文件操作的代码参考下,多谢了
- 布局问题
- java.lang.RuntimeException: Unable to create application * : java.lang.NullPoint
- 一个android的新浪微博sdk的问题
- 请教大神们一个问题
- 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);
看看是不是有区别