-3

i've problem setting the list view, When i create the array and i try to put into the list view, return error Cannot resolve constructor ArrayAdapter this is my array.

protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.xml_busqueda_proveedores);


ArrayList<HashMap<String, String>> arl = (ArrayList<HashMap<String, String>>) getIntent().getSerializableExtra("lista");

System.out.println("::: array " + arl); 
// This is the array
// ::: array [{1=111, 2= LOCAL }, {1=12, 2= CIUDAD}, {}, {}, {}]

list = (ListView)findViewById(R.id.ListProveedores);

ArrayAdapter<String> adaptador = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, arl);
//Error Cannot resolve constructor ArrayAdapter
list.setAdapter(adaptador);
}
1
  • ArrayAdapter<String> is useful only when you are using Simple Array or ArrayList. You are using ArrayList<HashMap<String, String>>.. So you need to use Custom Adapter. go with this link. stackoverflow.com/questions/33701943/… Commented May 11, 2016 at 18:47

1 Answer 1

1

Your problem is because you create an ArrayAdapter of String but you give to your adapter an ArrayList of HashMap of two strings.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.