Android ArrayAdapter<String> Error
I need to create a spinner from a string. Until now I use an ArrayAdapter, but it's not working. This is my code
ArrayList<String> aus=new ArrayList<String>();
if(results.length!=0){
for(int i=0;i<results.length;i++)
aus.add(results[i].get_nome());
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, aus);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
locale.setAdapter(adapter);
}
}
locale is a 开发者_JAVA百科Spinner type results it's a my class and get_nome return a string I have this error: "The costructor of ArrayAdapter(new Handler(){},int, ArrayList is undefined"
It seems that you're creating the adapter in an inner class.. You should do
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MyActivityClass.this,android.R.layout.simple_spinner_item, aus);
精彩评论