我在android studio的Main.Activity.kt
中有字符串代码,但我一直收到错误消息“函数声明必须有一个名称:unresolved reference”
@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) { \\ do price print.}
方法displayPrice
未声明,因此出现错误的引用错误。