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