I am referring to The Busy Coder's Guide to Android Development. It is a very well written book with a lot of useful technique. I haven’t bought one yet, I just finished a sample chapter.
In page 103
class IconicAdapter extends ArrayAdapter<String> {
IconicAdapter() {
super(DynamicDemo.this, R.layout.row, R.id.label, items);
}
public View getView(int position, View convertView, ViewGroup parent) {
View row=super.getView(position, convertView, parent);
ImageView icon=(ImageView)row.findViewById(R.id.icon);
However, in page 105
class IconicAdapter extends ArrayAdapter<String> {
IconicAdapter() {
super(DynamicDemo.this, R.layout.row, items);
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater=getLayoutInflater();
View row=inflater.inflate(R.layout.row, parent, false);
TextView label=(TextView)row.findViewById(R.id.label);
I was wondering, why do we need to use getLayoutInflater in the example page 105? Can’t we just get the view by
View row=super.getView(position, convertView, parent);
The sample chapter can be found at http://commonsware.com/Android/excerpt.pdf
It looks like in the first case the super class has already inflated the view for you and so you can do a super.getView() from it.
And in the second it looks like you are handling the inflating on your own and hence would need the shown code.