方法getLong(int)未定义为SherlockFragmentList

时间:2013-08-23 17:10:41

标签: android

我想在操作栏的标签上的SherlockFragmentList上显示联系人列表。我按照android develop tutorial但我在尝试获取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);

}

这里有什么帮助吗? 感谢

1 个答案:

答案 0 :(得分:6)

我认为缺少cursor,另请参阅reference

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