找不到适合 ArrayAdapter 的构造函数

no suitable constructor found for 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 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<String> stringArrayAdapter=new ArrayAdapter<String>(
                AllStores.this,
                lv,
                subprises);

我也试过用thisgetApplicationContext()context替换ArrayAdapter的第一个参数。不幸的是它没有用。我真的不知道我做错了什么。

如果你想看,可以在下面看到我的代码:

AllStores.java:

public class AllStores extends Activity {
    private ListView lv;
    Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_all_stores);
        lv = (ListView) findViewById(R.id.store_list);
        Response<List<Store>> subprises;
        try {
            subprises = new StoreService().getSubprises();
            Iterator it = subprises.body().iterator();
            ArrayAdapter<String> stringArrayAdapter=new ArrayAdapter<String>(
                    AllStores.this,
                    lv,
                    subprises);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

ArrayAdapter<String> 构造函数不接受 ListView 也不接受 Response<List<Store>> 并且在您的代码中您将它们都添加了

ArrayAdapter<String> stringArrayAdapter=new ArrayAdapter<String> AllStores.this, lv, subprises);

但它应该采用 Contextlayout resource idList<String>String[]。一个简单的适配器是

ArrayAdapter<String> adapter = new ArrayAdapter<>(AllStores.this, android.R.layout.simple_list_item_1, your_string_array_or_list);

然后将该适配器设置为您的 ListView

lv.setAdapter(adatper);

如果您想要更复杂的适配器,您应该创建一个自定义 ArrayAdapter。看看这个 link
http://www.ezzylearning.com/tutorial/customizing-android-listview-items-with-custom-arrayadapter