Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArrayAdapter is raw type warning?

I am creating a list view layout and receive an ArrayAdapter warning. The error message is below. The warning message is pointing to the following text:

new ArrayAdapter(this, android.R.layout.simple_list_item_1, populateList());

Any assistance will be helpful

warning message:

Description Resource Path Location Type ArrayAdapter is a raw type. References to generic type ArrayAdapter should be parameterized LoginList.java /LoginPlus/src/com/loginplus/home line 95 Java Problem

@Override
protected void onResume() {
    super.onResume();
loginListAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, populateList());
    loginList.setAdapter(loginListAdapter);
}
like image 316
user1165694 Avatar asked Feb 12 '12 00:02

user1165694


1 Answers

Use something like ArrayAdapter<Type> where "Type" is replaced with the actual type used by the ArrayAdapter.

For example:

ArrayAdapter<CharSequence>

As the warning says, this is because ArrayAdapter is generic, so you should specify the type it refers to so that the compiler can check that everything is good at compile time.

You can read more here.

like image 139
yydl Avatar answered Oct 05 '22 15:10

yydl