我所有的新Android和我试图以编程方式创建一个微调,并从一个数组它提供数据,但是Eclipse给了我一个警告,我无法处理。
I'm all new to Android and I'm trying to create a spinner programmatically and feeding it with data from an array, but Eclipse gives me a warning that I can't handle.
下面是我得到的答案:
这ArrayList中持有(被从后面上的文件填写)应在微调的元素:
This ArrayList holds the elements that should be in the spinner (gets filled from a file later on):
的ArrayList<字符串> spinnerArray =新的ArrayList<字符串>();
这是code我发现一个网站,应该创建微调:
This is code I found on a site which should create the spinner:
Spinner spinner = new Spinner(this);
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_dropdown_item,
spinnerArray);
spinner.setAdapter(spinnerArrayAdapter);
现在第二行(ArrayAdapter ...)给了我一个警告在Eclipse中说ArrayAdapter是一个原始类型......引用泛型类型ArrayAdapter< T>应参数
,我不知道如何解决这一问题(或者是什么意思摆在首位:))。
Now the second line (ArrayAdapter...) gives me a warning in Eclipse saying "ArrayAdapter is a raw type... References to generic type ArrayAdapter<T> should be parameterized"
, I have no idea how to fix this (or what that means in the first place :) ).
这只是一个警告,该应用程序似乎是正常的运行,但我仍想知道什么是错的,解决它。任何暗示是AP preciated。
It's just a warning and the App seems to run alright, but I'd still like to understand what's wrong and fix it. Any hint is appreciated.
问候, Select0r
Greetings, Select0r
ArrayAdapter&LT;字符串&GT;
应该
即:
Spinner spinner = new Spinner(this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerArray); //selected item will look like a spinner set from XML
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(spinnerArrayAdapter);