我有一个底部工作表,我想添加一个按钮,单击该按钮时底部工作表对话框将展开
enter image description here
是否可以将onclicklistener放在底部表单片段onCreateView中并更改对话框的状态?
这是我的底片碎片
public class RepliesToComment extends BottomSheetDialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
Window window = dialog.getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dialog.getBehavior().setState(BottomSheetBehavior.STATE_COLLAPSED); <--change to STATE_EXPANDED on click-->
return dialog;
}
ImageButton expandBtn;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_replies_to_comment, container, false);
{...}
expandBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
----
}
});
}
1条答案
按热度按时间ccrfmcuu1#
我设法使它工作这是我的解决方案
然后创建一个布尔标识符来切换对话框的状态
然后把按钮做成切换按钮来改变标识符的值