如果 OnCreateView 仅适用于片段,那么 Activity 会是什么?
我尝试了 OnCreate() 但无法使其工作
在第一个覆盖中我遇到了问题,在最后一个覆盖中它也给了我一个 OncreateView 错误。
我已阅读有关 OnCreate() 和 OnCreateView() 的信息,但找不到答案。
private VrPanoramaView panoWidgetView;
private ImageLoaderTask backgroundImageLoaderTask;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_pruebafoto, container,false);
panoWidgetView = v.findViewById(R.id.pano_view);
return v;
}
@Override
public void onPause() {
panoWidgetView.pauseRendering();
super.onPause();
}
@Override
public void onResume() {
panoWidgetView.resumeRendering();
super.onResume();
}
@Override
public void onDestroy() {
// Destroy the widget and free memory.
panoWidgetView.shutdown();
super.onDestroy();
}
private synchronized void loadPanoImage() {
ImageLoaderTask task = backgroundImageLoaderTask;
if (task != null && !task.isCancelled()) {
// Cancel any task from a previous loading.
task.cancel(true);
}
// pass in the name of the image to load from assets.
VrPanoramaView.Options viewOptions = new VrPanoramaView.Options();
viewOptions.inputType = VrPanoramaView.Options.TYPE_STEREO_OVER_UNDER;
// use the name of the image in the assets/ directory.
String panoImageName = "@drawable/iglesiavr.jpg";
// create the task passing the widget view and call execute to start.
task = new ImageLoaderTask(panoWidgetView, viewOptions, panoImageName);
task.execute(this.getAssets());
backgroundImageLoaderTask = task;
}
@Override
public void onCreateView(@Nullable Bundle savedInstanceState) {
super.onCreateView(savedInstanceState);
loadPanoImage();
}