BottomSheetDialogFragment内部片段问题

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

[在Fragment内显示BottomSheetDialogFragment并与特定按钮交互(例如,根据下面的照片增加价格后,该Fragment消失并按第二张照片显示。

代码:

increase_price.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String coun_cost = shipment_price.getText().toString();

            if (coun_cost.isEmpty()) {
                counter_price = 0;
                counter_price = counter_price + 5;
                requestFocus(shipment_price);
                shipment_price.setText(String.valueOf(counter_price));
            } else {
                counter_price = Integer.valueOf(coun_cost);
                counter_price = counter_price + 5;
                requestFocus(shipment_price);
                shipment_price.setText(String.valueOf(counter_price));
            }
        }
    });

    decrement_price.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String coun_cost = shipment_price.getText().toString();

            if (!coun_cost.isEmpty()) {
                counter_price = Integer.valueOf(coun_cost);
                counter_price = counter_price - 5;
                if (counter_price >= 0) {
                    requestFocus(shipment_price);
                    shipment_price.setText(String.valueOf(counter_price));
                } else {
                    counter_price = 0;
                    requestFocus(shipment_price);
                    shipment_price.setText(String.valueOf(counter_price));
                }
            }
        }
    });

enter image description here

enter image description here

android-fragments dialog bottom-sheet
1个回答
0
投票

删除下面的代码行后我解决了我的问题。

    param = Objects.requireNonNull(getActivity()).getWindow().getAttributes();
    param.width = WindowManager.LayoutParams.MATCH_PARENT;
    param.height = WindowManager.LayoutParams.DIM_AMOUNT_CHANGED;
© www.soinside.com 2019 - 2024. All rights reserved.