我的 Android studio 的 Main.Activity.kt
中有代码字符串,但我不断收到错误消息“函数声明必须有名称:未解析的引用”
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/**
* This method is called when the order button is clicked.
*/
public void submitOrder(View view) {
display(2);
displayPrice(2*5);
}
/**
* This method displays the given quantity value on the screen.
*/
private void display(int number) {
TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
quantityTextView.setText("" + number);
}
}
最佳答案
将(但这不是你想要的)displayPrice(2*5);
替换为display(2*5);
(只是为了解决未引用的错误,然后您将看到价格而不是数量)。还要显示您需要创建的方法的价格:
private void displayPrice(int number) {
\\打印价格。
}
方法displayPrice
未声明,这就是出现错误引用错误的原因。
关于java - 函数声明必须有名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47653332/