Android 导航元素don';我看不到碎片

Android 导航元素don';我看不到碎片,android,Android,我有一个包含片段和活动的项目。我想尝试导航元素,但我不能在我的图上添加片段-在目标列表中,我只有活动。为什么会这样 Androidx,Java UPD:我找不到此导航元素的正确标记,因此只有Android标记存在 擦伤: implementation 'android.arch.navigation:navigation-fragment:1.0.0' implementation "android.arch.navigation:navigation-ui:1.0.0" activity_m

我有一个包含片段和活动的项目。我想尝试导航元素,但我不能在我的图上添加片段-在目标列表中,我只有活动。为什么会这样

Androidx,Java

UPD:我找不到此导航元素的正确标记,因此只有
Android
标记存在

擦伤:

implementation 'android.arch.navigation:navigation-fragment:1.0.0'
implementation "android.arch.navigation:navigation-ui:1.0.0"
activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.MainActivity">

    <fragment
        android:id="@+id/my_nav_host_fragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:defaultNavHost="true"
        app:navGraph="@navigation/main_graph" />

</androidx.constraintlayout.widget.ConstraintLayout>
目标列表中没有碎片的屏幕:

而且,我认为重要的是,我对主要活动的预览:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

我不知道为什么,但它是灰色的。 UPD1:最后一个屏幕上的红色标记为:

A <fragment> tag allows a layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout you would like previewed while editing the layout.
标记允许布局文件在运行时动态包含不同的布局。在版面编辑时,不知道要使用的特定版面。您可以选择编辑布局时要预览的布局。

我想这可以解释为什么我在预览布局上的灰色片段在运行时是未知的。因此,我的问题与它无关。

当我在导航图上手动创建一个片段并执行“无效/重新启动”时,问题就解决了。

您是否检查了右上角的红色感叹号,该感叹号可能表示您有一个警告/错误,该警告/错误可能导致或可能不会导致您的问题,我读了红色感叹号并更新了我的问题。不幸的是,这与我的问题之间没有联系。
tools:layout=“@layout/fragment1”
上查看我的片段布局,ty.=)我认为主要的问题是关于项目,我创建了一个新的项目,其中包含了几个片段和所有的工作。但目前的项目太大,无法以这种方式迁移他。