在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));
}
}
}
});
答案 0 :(得分:0)
删除下面的代码行后,我解决了问题。
param = Objects.requireNonNull(getActivity()).getWindow().getAttributes();
param.width = WindowManager.LayoutParams.MATCH_PARENT;
param.height = WindowManager.LayoutParams.DIM_AMOUNT_CHANGED;