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