gpt4 book ai didi

java - 初始化数量

转载 作者:行者123 更新时间:2023-12-02 04:18:50 24 4
gpt4 key购买 nike

我希望当我的应用程序启动时,它显示 2 作为初始数量。总是显示0。我该怎么办?

 /**
* This method is called when the order button is clicked.
*/
public void submitOrder(View view) {
int quantity = 2;

displayPrice (quantity * 5);
}



/**
* This method is called when plus button is clicked.
*/

public void increment(View view) {
int quantity = 2;
quantity = quantity + 1;

display(quantity);

}
/**
* This method is called when minus button is clicked.
*/
public void decrement(View view) {
int quantity = 1;
display (quantity);
}

enter image description here

最佳答案

您可以在 Activity 的 onCreate 方法中调用 display(2); 或编辑 xml 布局,使数量 TextView 的值默认为 2。

关于java - 初始化数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33015290/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com