为什么setSelection方法在onLoadFinished中不起作用?

时间:2012-09-17 19:14:47

标签: android

我想在onLoadFinished方法的ListFragment中设置选择,但Log.v(TAG,“onLoadFinished:Selected id - >”+ getSelectedItemId()); line return onLoadFinished:Selected id - > -9223372036854775808?

有什么问题?

 public void onLoadFinished(Loader<LoaderResult> loader, LoaderResult data) {
    adapter.swapCursor(data.cursor);

    // The list should now be shown.
    if (isResumed()) {
        setListShown(true);
    } else {
        setListShownNoAnimation(true);
    }
    if (data.cursor.getCount() > 0) {
        setSelection(0);
        Log.v(TAG, " onLoadFinished: Selected id -> " + getSelectedItemId());
    }        
}

谢谢!

0 个答案:

没有答案