开发者

Android ArrayAdapter<String> Error

开发者 https://www.devze.com 2023-03-16 22:47 出处:网络
I need to create a spinner from a string. Until now I use an ArrayAdapter, but it\'s not working. This is my code

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消