What's T[] Object?
Solution 1:
The T is either a concrete class type (unlikely), or it is a class generic. Look at your class heading to see if this is the case.
IE
Class SomeClassType<T> {}
Tutorials on generics and how they work can be found here http://docs.oracle.com/javase/tutorial/java/generics/index.html
Solution 2:
http://docs.oracle.com/javase/tutorial/java/generics/gentypes.html
It is a generic type, which means that you can give any type you want to replace the T generic type.
Solution 3:
T[] means generic type. Here is documentation on generics.
Solution 4:
As has been mentioned, T
in this case refers to a generic type. In other words, an ArrayAdapter
can be used to handle objects of any type in order to bind the textual representation of those objects to Android TextViews
.
A simple example would be to use an array of type String
...
ArrayAdapter<String> myArrayAdapter;
String[] myArray = new String[] { "Hello", "World" } ;
myArrayAdapter = new ArrayAdapter<String>(this, R.id.my_textview, myArray);
Using Strings
for ArrayAdapter
is probably the most common approach although any object which implements toString()
to return something meaningful can be used...
ArrayAdapter<SomeObject> myArrayAdapter;
SomeObject[] myArray = new SomeObject[] { ... } ;
myArrayAdapter = new ArrayAdapter<SomeObject>(this, R.id.my_textview, myArray);
As long as SomeObject.toString()
is implemented then the TextView
represented by the resource id R.id.my_textview
will be bound to its return value.
Post a Comment for "What's T[] Object?"