osimer pothe osimer pothe - 1 year ago 165
Android Question

Error in OnItemClickListener in ListView IN Android

I have following line in my activity class .

listView1.setOnItemClickListener(new OnItemClickListener() {

public void onItemClick(AdapterViewCompat<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub


And eclipse gives me the following error :

The method setOnItemClickListener(AdapterView.OnItemClickListener) in the type AdapterView<ListAdapter> is not applicable for the arguments (new AdapterViewCompat.OnItemClickListener(){})

Why am I getting this error ? Please help me .

Answer Source

Add the below import to your code

 import android.widget.AdapterView.OnItemClickListener;

instead of the below import

 import android.support.v7.internal.widget.AdapterViewCompat.OnItemClickListener
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download