First, I don't see where inflater
is a field of MyFragment
, so that's a problem.
Second, I would recommend against keeping a reference to an inflater. It's cheap enough to obtain an inflater with:
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
(assuming you have access to a context
somewhere.) Also, I don't know what kind of adapter has a method viewAt(int)
. The usual signature is:
public View getView(int position, View convertView, ViewGroup parent) {
. . .
}
For performance reasons, you should definitely not inflate a new view on every call to this method. Instead you should check whether the convertView
argument is already a view of the expected type and only inflate a new view if it won't work.