我想将API中的信息加载到Fragment.
我使用getSupportLoaderManager()但发生错误:
无法解析方法:getSupportLoaderManager()
我搜索这个用途,onActivityCreated()但我有NullPointerException.
你能帮我解决一下这个问题吗?
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class Business extends Fragment implements LoaderManager.LoaderCallbacks<String> {
ListView listView;
public Business() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_business, container, false);
listView = view.findViewById(R.id.list_item);
getSupportLoaderManager().initLoader(0, null, getContext()).forceLoad();
return view;
}
@Override
public Loader<String> onCreateLoader(int id, Bundle args) {
return null; …Run Code Online (Sandbox Code Playgroud)