无法解析符号 'listener'
Cannot resolve symbol 'listener'
我的以下代码中出现以下错误 "Cannot resolve symbol 'listener'",但似乎无法摆脱它。关于为什么会出现此错误的任何想法?
public void onClick(View v) {
Spinner spr = (Spinner) findViewById(R.id.planspinner);
EditText editText6 =(EditText) findViewById(R.id.editText6);
TextView textView8 =(TextView) findViewById(R.id.textView8);
String selectedItem =(String) spr.getSelectedItem();
int intItemPosition =spr.getSelectedItemPosition();
if (selectedItem.trim().equals("*")){
float result = Float.parseFloat(editText6.getText().toString()) * Float.parseFloat(Integer.toString(planlist.get(intItemPosition).getCalories()));
textView8.setText(Float.toString(result));
}
Button button4 = (Button)findViewById(R.id.button4);
button4.setOnClickListener(listener);
}
需要声明的侦听器:
private planOnClickListener myClickListener = new planOnClickListener();
并适当 link 给听众:
Button button4 = (Button)findViewById(R.id.button4);
button4.setOnClickListener(myClickListener);
我的以下代码中出现以下错误 "Cannot resolve symbol 'listener'",但似乎无法摆脱它。关于为什么会出现此错误的任何想法?
public void onClick(View v) {
Spinner spr = (Spinner) findViewById(R.id.planspinner);
EditText editText6 =(EditText) findViewById(R.id.editText6);
TextView textView8 =(TextView) findViewById(R.id.textView8);
String selectedItem =(String) spr.getSelectedItem();
int intItemPosition =spr.getSelectedItemPosition();
if (selectedItem.trim().equals("*")){
float result = Float.parseFloat(editText6.getText().toString()) * Float.parseFloat(Integer.toString(planlist.get(intItemPosition).getCalories()));
textView8.setText(Float.toString(result));
}
Button button4 = (Button)findViewById(R.id.button4);
button4.setOnClickListener(listener);
}
需要声明的侦听器:
private planOnClickListener myClickListener = new planOnClickListener();
并适当 link 给听众:
Button button4 = (Button)findViewById(R.id.button4);
button4.setOnClickListener(myClickListener);