Note that there are some explanatory texts on larger screens.

plurals
  1. POThe type new AdapterView.OnItemSelectedListener(){} must implement the inherited abstract method error. Eclipse
    text
    copied!<p>I am a begginer in android programming and have yet run into another problem. I am making a simple spinner app. Here is the code.</p> <pre><code>package net.learn2develop.Basicviews6; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; public class BasicViews6Activity extends Activity { String[] presidents; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); presidents = getResources().getStringArray(R.array.presidents_array); Spinner s1 = (Spinner) findViewById(R.id.spinner1); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, presidents); s1.setAdapter(adapter); s1.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { int index = arg0.getSelectedItemPosition(); Toast.makeText(getBaseContext(), "You have selected item : " + presidents[index], Toast.LENGTH_SHORT).show(); } @Override public Void onNothingdSelected(AdapterView&lt;?&gt; arg0) { } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.basic_views6, menu); return true; } } </code></pre> <p>But It wont let me run it because theses lines of code:</p> <pre><code> s1.setOnItemSelectedListener(new OnItemSelectedListener() public Void onNothingdSelected(AdapterView&lt;?&gt; arg0) </code></pre> <p>have the error that reads:</p> <p>The type new AdapterView.OnItemSelectedListener(){} must implement the inherited abstract method AdapterView.OnItemSelectedListener.onNothingSelected(AdapterView)</p> <p>Could someone enlighten me? Any help will be much appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload