答案 0 :(得分:3)
您正试图在 fab 中找到 fab ,在 fab1 中找到 fab1 ... 您需要从片段的根视图中获取这些按钮。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.carte_reseaux_fragment, container, false);
fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
.
.
Animation fab_open = AnimationUtils.loadAnimation(getContext(), R.anim.fab_open);
//Actually FloatingActionButton has own implementation
fab.setShowAnimation(fab_open);
return rootView;
}