你好,我有一个bottomsheet
使用一些文本视图(作为按钮),按下时它会导航到不同的片段,但问题是当textView
被按下并导航到片段仍然底部工作表没有隐藏,最终必须点击屏幕才能隐藏底部工作表,我希望当片段启动时底部工作表将隐藏,这是我遇到的问题的屏幕记录得到link https://drive.google.com/file/d/1KF-aSjSQ3MeQMH-RV6Zkk9ICuDJVluDK/view?usp=sharing
Profile_Fragment.java
ImageView accountSettings = view.findViewById(R.id.account_Settings);
accountSettings.setOnClickListener(
v -> {
BottomSheet bottomSheet = new BottomSheet();
bottomSheet.show(requireActivity().getSupportFragmentManager(), bottomSheet.getTag());
}
);
BottomSheet.java
public class BottomSheet extends BottomSheetDialogFragment {
public BottomSheet() {
}
@Nullable
@org.jetbrains.annotations.Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.bottom_sheet_profile, container, false);
TextView settingsProfileTextView = view.findViewById(R.id.settings);
settingsProfileTextView.setOnClickListener(v -> {
Fragment settings_profile = new Settings_Profile();
FragmentTransaction transaction = getParentFragmentManager().beginTransaction();
transaction.add(R.id.fragment_container, settings_profile);
transaction.addToBackStack(String.valueOf(settings_profile));
transaction.commit();
});
TextView editProfileTextView = view.findViewById(R.id.edit_profile);
editProfileTextView.setOnClickListener(v -> {
Fragment edit_profile = new Edit_Profile();
FragmentTransaction transaction = getParentFragmentManager().beginTransaction();
transaction.add(R.id.fragment_container, edit_profile);
transaction.addToBackStack(String.valueOf(edit_profile));
transaction.commit();
});
return view;
}
}
编辑配置文件.java// 当textView被按下时打开的fragment
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_edit_profile, container, false);
profilePhoto = view.findViewById(R.id.circleImageView);
initImageLoader();
setProfileImage();
ImageView imageView = view.findViewById(R.id.backArrow);
imageView.setOnClickListener(v -> {
Fragment newCase = new Profile_Fragment();
assert getFragmentManager() != null;
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, newCase);
transaction.disallowAddToBackStack();
transaction.commit();
});
return view;
}