我有一个片段:
AnimationFragment.java
public class AnimationFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.animation_fragment, container, false);
view.findViewById(R.id.animationBox)
return view;
}
}
我在Fragment中有一个带有animationBox id的视图:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View android:id="@+id/animationBox"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
然而,当我尝试引用R.id.animationBox时,Android Studio会以红色突出显示它,并表示找不到符号。为什么会这样?