方法initLoader问题

时间:2014-11-13 11:17:47

标签: java android events compiler-errors

在MainActivity类中,java:

  public class MainActivity extends FragmentActivity implements 
  LoaderManager.LoaderCallbacks<Cursor> {

public void onClickBtnDispNames(View view) {
    getSupportLoaderManager().initLoader(1, null, this);
}
}

出现错误:

The method initLoader(int, Bundle, LoaderManager.LoaderCallbacks<D>) in the type LoaderManager is    
 not applicable for the arguments (int, null, MainActivity)

2 个答案:

答案 0 :(得分:0)

确保从同一个LoaderManager包中导入android.support.v4.*及相关类。

import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
...

答案 1 :(得分:0)

可能错误的是您要导入android.app.LoaderManagergetSupportLoaderManager正在寻找android.support.v4.LoaderManager类。