I have a custom view that I would like to create from a resource template. My custom view designer accepts additional parameters that are set as additional information for the custom view.
The problem is that when I inflate the view, I get a view object that is not a subclass of the user view, since the inflation method is static and returns a general new view instead of an instance of my user view.
I was looking for a way to inflate the view by passing it my own reference to the view object.
public class MLBalloonOverlayView extends View {
MiscInfo mMiscInfo;
public MLBalloonOverlayView (Context context, MiscInfo miscInfo) {
super (context);
mMiscInfo = miscInfo;
}
public View create (final int resource, final OverlayItem item,
MapView mapView, final int markerID) {
ViewGroup viewGroup = null;
View balloon = View.inflate (getContext (), resource, viewGroup);
// I want to return this object so later I can use its mMiscInfo
// return this;
return balloon;
}
}
source share