I imported the wrong interface (java one) the correct one is:
android.widget.AdapterView.OnItemClickListener
Question
I'm trying to add a listenner to my listview but I get many errors, including this one:
Description Resource Path Location Type The method
setOnItemClickListener(AdapterView.OnItemClickListener) in the type AdapterView is not applicable for the arguments (new OnItemClickListener(){}) GlossaryActivity.java /line 109 Java Problem
Here is my code:
// Initialize the UI components
ListView GlossaryListView = (ListView) findViewById(R.id.listView1);
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, TermsArray);
GlossaryListView.setAdapter(arrayAdapter);
GlossaryListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a,
View v, int position, long id) {
}
});
I placed this piece of code inside of onCreate method. How do I fix this
Solution
I imported the wrong interface (java one) the correct one is:
android.widget.AdapterView.OnItemClickListener