2017-03-15 53 views
-1

这是我的代码:错误填充微调使用数据库值

设置内容的浏览声明:

GetDataAdapter1 = new ArrayList<>(); 

     // spinner item select listener 
     spinnerCountry.setOnItemSelectedListener(this); 

这是i'm使用JSON请求我的分析值。

public void JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array) { 

    for (int i = 0; i < array.length(); i++) { 

     Country GetDataAdapter2 = new Country(); 

     JSONObject json = null; 
     try { 

      json = array.getJSONObject(i); 

      GetDataAdapter2.setName(json.getString("country_name")); 
      GetDataAdapter2.setId(json.getString("id")); 


     } catch (JSONException e) { 

      e.printStackTrace(); 
     } 
     GetDataAdapter1.add(GetDataAdapter2); 
    } 


    //Setting adapter to show the items in the spinner 
    spinnerCountry.setAdapter(new ArrayAdapter<String>(DataComplet.this, android.R.layout.simple_spinner_dropdown_item, GetDataAdapter1)); 

} 

这是我得到的错误:

Cannot resolve constructor 'ArrayAdapter(com.futegolo.jobnow.DataComplet, int, java.util.List<com.futegolo.jobnow.Configs.Country>)' 

回答

0

您正在使用自定义的模型对象Country加载微调,这是不行的:

spinnerCountry.setAdapter(new ArrayAdapter<String>(DataComplet.this, android.R.layout.simple_spinner_dropdown_item, GetDataAdapter1)); 

试试这个:

ArrayAdapter<Country> adapter = 
       new ArrayAdapter<Country>(getApplicationContext(), R.layout.simple_spinner_dropdown_item, GetDataAdapter1); 
adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); 

spinnerCountry.setAdapter(adapter);