0
我希望当我的应用程序启动时,它显示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);
}
在'onCreate'参考初始化后把'yourTextView.setText(String.valueOf(2));' – Rustam
设置为静态值,如2 – Androider
你添加到你的文章中的那段代码没用。 – jhamon