开发者

Custom ListView - cannot instantiate the type ListAdapter

开发者 https://www.devze.com 2023-03-13 14:32 出处:网络
I have this code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

I have this code:

public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   ListView lv = (ListView) findViewById(R.i开发者_如何学Cd.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.


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)


See Custom Listview.

0

精彩评论

暂无评论...
验证码 换一张
取 消