【发布时间】:2019-11-25 14:08:18
【问题描述】:
在 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));
}
}
}
});
【问题讨论】:
-
向我们展示您的代码。
-
@JohnJoe 代码已添加。
-
你能显示整个片段类吗,我不认为上面的代码有任何错误
标签: android-fragments dialog bottom-sheet