4

我想在操作栏中的选项卡上的 SherlockFragmentList 上显示联系人列表。我遵循android开发教程 ,但是当我尝试在onItemClick方法中获取id值时出现以下错误:(方法getLong(int)对于ContactListFragment类型未定义)

 public class ContactListFragment extends SherlockListFragment implements LoaderCallbacks<Cursor>,
        AdapterView.OnItemClickListener { 
    @Override
    public void onItemClick(AdapterView<?> parent, View item, int position, long rowID) {
    //Get The Cursor
    Cursor cursor = ((SimpleCursorAdapter) parent.getAdapter()).getCursor();
    //move to the selected contact
    cursor.moveToPosition(position);
    //get the id value
    mContactId = getLong(CONTACT_ID_INDEX);
    mContactKey = getString(LOOKUP_KEY_INDEX);
    mContactUri = Contacts.getLookupUri(mContactId, mcontactKey);

}

这里有什么帮助吗?谢谢

4

1 回答 1

6

我认为cursor缺少 a ,另请参阅参考

Cursor cursor = ((SimpleCursorAdapter) parent.getAdapter()).getCursor();
//move to the selected contact
cursor.moveToPosition(position);
//get the id value
mContactId = cursor.getLong(CONTACT_ID_INDEX);
mContactKey = cursor.getString(LOOKUP_KEY_INDEX);

编辑:为此问题填充了错误59330

于 2013-08-23T17:12:52.627 回答