当我试图膨胀时,片段没有出现在建议中

问题描述 投票:0回答:1

我试图给我的一个碎片充气。但是,片段不会出现在autosuggest中。所以我手动输入了片段的名称。通过这样做,片段名称以红色文本颜色显示,并且红色波浪线显示在所有类名称下面。但是,当我运行应用程序时,它运行完美,没有任何错误。

我有三个片段:fragment_dynamic_android.xmlfragment_dynamic_windows.xmlfragment_dynamic_ios.xml

我可以用fragment_dynamic_android.xml方法在AndroidFragment.java类中膨胀onCreateView

但是当我试图在fragment_dynamic_windows.xmlWindowsFragment.java方法上膨胀onCreateView时。

红色文本颜色正在显示

查看rootView = inflater.inflate(R.layout.fragment_dynamic_windows,container,false);

应用程序运行没有任何错误。

package app.tab.simple.fragmenttut;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class WindowsFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_dynamic_windows, container, false);
        return rootView;
    }
}
java android android-fragments android-inflate
1个回答
0
投票

经过一番挫折之后,关闭电脑并开始做一些事情。又来了,打开了项目,错误消失了。不知道为什么android studio表现得那样。

© www.soinside.com 2019 - 2024. All rights reserved.