2

I have this code:

public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   ListView lv = (ListView) findViewById(R.id.lvResult);
   ListAdapter listAdapter = new ListAdapter(Prueba.this, imageList, list1, list2);
   lv.setAdapter(listAdapter);
}

And it gives an Error:
Cannot instantiate the type ListAdapter

In the same package, I have created a class called ListAdapter.java with its code.
I don't know what that error means.

2 Answers 2

11

ListAdapter is also a class in the android.widget package. It is possible that you are importing this, and this is trying to be instantiated rather than your local ListAdapter class.

Your options are:

  1. Try renaming your ListAdapter class to something different, to remove the possible conflict.
  2. Remove import android.widget.ListAdapter; or import android.widget.*; from your code.
  3. fully qualify the class that you want to use (i.e. com.mycompany.ListAdapter)
1
  • Yes, i have renamed the class, and everything alright. Thank you ;)
    – fr4n
    Jun 16, 2011 at 9:48
0

See Custom Listview.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.