本文介绍了getSupportFragmentManager() 不可访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.net.Uri;
import android.view.Gravity;
import android.view.MotionEvent;
import android.widget.ImageButton;
import android.widget.Toast;
import com.google.ar.core.Anchor;
import com.google.ar.core.HitResult;
import com.google.ar.core.Plane;
import com.google.ar.sceneform.AnchorNode;
import com.google.ar.sceneform.rendering.ModelRenderable;
import com.google.ar.sceneform.ux.ArFragment;
import com.google.ar.sceneform.ux.BaseArFragment;
import com.google.ar.sceneform.ux.TransformableNode;
import com.google.ar.sceneform.math.Quaternion;
import com.google.ar.sceneform.math.Vector3;
import android.view.View;
public class MainActivity extends AppCompatActivity {
private ArFragment arFragment;
private ModelRenderable modelRenderable;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.fragment);
出现错误:
Inconvertible types; cannot cast 'androidx.fragment.app.Fragment' to 'com.google.ar.sceneform.ux.ArFragment'
我已经为片段添加了导入?
I have add the import for fragment?
在构建过程中也出现这个错误.
Also giving this Error during Build.
sceneformsrc\sceneform\src\main\java\com\google\ar\sceneform\AnchorNode.java:3: 错误:包 android.support.annotation 不存在导入 android.support.annotation.Nullable;
sceneformsrc\sceneform\src\main\java\com\google\ar\sceneform\AnchorNode.java:3: error: package android.support.annotation does not existimport android.support.annotation.Nullable;
因为我收到这些错误而遗漏了什么?
am missing something that I am getting these errors?
我使用的是 Sceneform 1.16 和 Andriod studio 4.1
I am using Sceneform 1.16 and Andriod studio 4.1
推荐答案
<fragment
android:id="@+id/face_fragment"
android:name="com.google.ar.sceneform.ux.ArFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
你有没有提到 android:name 标签?
Have you mentioned the android:name tag?
这篇关于getSupportFragmentManager() 不可访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!