Java 找不到适合ArrayAdapter的构造函数
我得到以下错误:Java 找不到适合ArrayAdapter的构造函数,java,android,android-arrayadapter,Java,Android,Android Arrayadapter,我得到以下错误: Error:(34, 53) error: no suitable constructor found for ArrayAdapter(AllStores,ListView,Response<List<Store>>) constructor ArrayAdapter.ArrayAdapter(Context,int,int,List<String>) is not applicable (actual and formal argumen
Error:(34, 53) error: no suitable constructor found for ArrayAdapter(AllStores,ListView,Response<List<Store>>)
constructor ArrayAdapter.ArrayAdapter(Context,int,int,List<String>) is not applicable
(actual and formal argument lists differ in length)
constructor ArrayAdapter.ArrayAdapter(Context,int,List<String>) is not applicable
(actual argument ListView cannot be converted to int by method invocation conversion)
constructor ArrayAdapter.ArrayAdapter(Context,int,int,String[]) is not applicable
(actual and formal argument lists differ in length)
constructor ArrayAdapter.ArrayAdapter(Context,int,String[]) is not applicable
(actual argument ListView cannot be converted to int by method invocation conversion)
constructor ArrayAdapter.ArrayAdapter(Context,int,int) is not applicable
(actual argument ListView cannot be converted to int by method invocation conversion)
constructor ArrayAdapter.ArrayAdapter(Context,int) is not applicable
(actual and formal argument lists differ in length)
ArrayAdapter
构造函数不接受ListView
或Response
,您在代码中添加了它们
ArrayAdapter<String> stringArrayAdapter=new ArrayAdapter<String> AllStores.this, lv, subprises);
然后将该适配器设置为ListView
lv.setAdapter(adatper);
如果您想要更复杂的适配器,您应该创建一个自定义的ArrayAdapter
。查看此链接您正试图在
字符串的数组列表中传递响应的对象
。您必须创建自己的适配器类来扩展数组适配器
,然后将其设置为这样。默认构造函数需要Context
、layoutId、StringArray
…您可以查看自定义适配器的实现
ArrayAdapter<String> stringArrayAdapter=new ArrayAdapter<String> AllStores.this, lv, subprises);
ArrayAdapter<String> adapter = new ArrayAdapter<>(AllStores.this, android.R.layout.simple_list_item_1, your_string_array_or_list);
lv.setAdapter(adatper);