OK, so I’m pretty new to this, but I’m getting it. I just ran into this error and I have seen other people have had the same problem, but the standard fix (clean) doesn’t work for me. I have no clue how to fix these errors! HELP PLEASE!
first error:
on sp2.setOnItemSelectedListener(new OnItemSelectedListener() { in my else if statement I keep geting this error:
The type new AdapterView.OnItemSelectedListener(){} must implement the inherited abstract method AdapterView.OnItemSelectedListener.onNothingSelected(AdapterView)
I have the onNothingSelected there, and it works in my if statement, I mean all I did was copy and paste and edit.
second error:
on }); at the end of my else if statement i get the error:
Syntax error, insert “;” to complete Statement
but everything is there. the statement is completed!
sp1.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelecteds(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
String reg_select = (sp1.getSelectedItem().toString());
if (reg_select.contentEquals("Southwest")){
sp2.setAdapter(sw_cit_adp);
sp2.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String sw_cit_select = (sp2.getSelectedItem().toString());
if (sw_cit_select.contentEquals("Lake Charles")){
sp3.setAdapter(sw_lake_charles_adp); }
else if (sw_cit_select.contentEquals("Iowa")){
sp3.setAdapter(sw_iowa_adp); }
;}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
};});}
else if (reg_select.contentEquals("South Central")){
sp2.setAdapter(sc_cit_adp);
sp2.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String sc_cit_select = (sp2.getSelectedItem().toString());
if (sc_cit_select.contentEquals("Lafayette")){
sp3.setAdapter(sc_lafayette_adp); }
else if (sc_cit_select.contentEquals("Gueydan")){
sp3.setAdapter(sc_gueydan_adp); }
;}
public void onNothingSelected(
AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
;
});
}
You have that method in the wrong place. You can’t have an item selected and nto select anything, that’s non-sensical.
You need to put the method under the listener, like the
onItemSelected, but not insideonItemSelected.This is what it should (basically) look like:
Oh, and you need to use the exact method name… it’s
onItemSelectednotonItemSelecteds