Most visited

Recently visited

LoaderManager

public abstract class LoaderManager
extends Object

java.lang.Object
   ↳ android.support.v4.app.LoaderManager


静态库支持版本的框架LoaderManager 。 用于编写在Android 3.0之前的平台上运行的应用程序。 在Android 3.0或更高版本上运行时,此实现仍在使用; 它不会尝试切换到框架的实现。 请参阅框架SDK文档以了解类概述。

您的活动必须来自 FragmentActivity才能使用。

Summary

Nested classes

interface LoaderManager.LoaderCallbacks<D>

客户端与管理器进行交互的回调接口。

Public constructors

LoaderManager()

Public methods

abstract void destroyLoader(int id)

停止并删除具有给定ID的加载程序。

abstract void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)

将LoaderManager的状态打印到给定的流中。

static void enableDebugLogging(boolean enabled)

控制框架的内部加载器管理器调试日志是否打开。

abstract <D> Loader<D> getLoader(int id)

如果没有找到匹配的加载程序,则返回具有给定标识的Loader或null。

boolean hasRunningLoaders()

如果任何托管的加载器当前正在运行并且尚未将数据返回给应用程序,则返回true。

abstract <D> Loader<D> initLoader(int id, Bundle args, LoaderCallbacks<D> callback)

确保加载程序已初始化并处于活动状态。

abstract <D> Loader<D> restartLoader(int id, Bundle args, LoaderCallbacks<D> callback)

在此管理器中启动新的或重新启动现有 Loader , Loader注册回调,并且(如果活动/片段当前已启动)开始加载它。

Inherited methods

From class java.lang.Object

Public constructors

LoaderManager

LoaderManager ()

Public methods

destroyLoader

void destroyLoader (int id)

停止并删除具有给定ID的加载程序。 如果此加载器以前曾通过onLoadFinished(Loader, Object)向客户报告数据,则将致电onLoaderReset(Loader) 。

Parameters
id int

dump

void dump (String prefix, 
                FileDescriptor fd, 
                PrintWriter writer, 
                String[] args)

将LoaderManager的状态打印到给定的流中。

Parameters
prefix String: Text to print at the front of each line.
fd FileDescriptor: The raw file descriptor that the dump is being sent to.
writer PrintWriter: A PrintWriter to which the dump is to be set.
args String: Additional arguments to the dump request.

enableDebugLogging

void enableDebugLogging (boolean enabled)

控制框架的内部加载器管理器调试日志是否打开。 如果启用,当框架执行加载操作时,您将在logcat中看到输出。

Parameters
enabled boolean

getLoader

Loader<D> getLoader (int id)

如果没有找到匹配的加载程序,则返回具有给定标识的Loader或null。

Parameters
id int
Returns
Loader<D>

hasRunningLoaders

boolean hasRunningLoaders ()

如果任何托管的加载器当前正在运行并且尚未将数据返回给应用程序,则返回true。

Returns
boolean

initLoader

Loader<D> initLoader (int id, 
                Bundle args, 
                LoaderCallbacks<D> callback)

确保加载程序已初始化并处于活动状态。 如果加载程序不存在,则创建一个加载程序(如果活动/碎片当前已启动)将启动加载程序。 否则,重新使用最后创建的加载器。

无论哪种情况,给定的回调函数都与加载器相关联,并且随着加载器状态更改而调用。 如果在调用点处调用者处于启动状态,并且所请求的加载器已经存在并且已经生成了其数据,那么将立即调用回调onLoadFinished(Loader , D) (在此函数内部),因此您必须为此做好准备。

Parameters
id int: A unique identifier for this loader. Can be whatever you want. Identifiers are scoped to a particular LoaderManager instance.
args Bundle: Optional arguments to supply to the loader at construction. If a loader already exists (a new one does not need to be created), this parameter will be ignored and the last arguments continue to be used.
callback LoaderCallbacks: Interface the LoaderManager will call to report about changes in the state of the loader. Required.
Returns
Loader<D>

restartLoader

Loader<D> restartLoader (int id, 
                Bundle args, 
                LoaderCallbacks<D> callback)

在此管理器中启动新的或重新启动现有的Loader , Loader注册回调,并且(如果活动/片段当前已启动)开始加载它。 如果以前已经启动了一个具有相同ID的加载器,那么当新加载器完成其工作时,它将自动被销毁。 回调将在旧加载器销毁之前交付。

Parameters
id int: A unique identifier for this loader. Can be whatever you want. Identifiers are scoped to a particular LoaderManager instance.
args Bundle: Optional arguments to supply to the loader at construction.
callback LoaderCallbacks: Interface the LoaderManager will call to report about changes in the state of the loader. Required.
Returns
Loader<D>

Hooray!