I am looking for a way that allows me access an object from another class; both classes are within the same Android activity – OpenStreeMapActivity.java. I have:
ItemizedOverlay.java – Contains the object I want to access and modify:
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
BalloonOverlayView.java – Is where I want to access the object mOverlays:
protected void setupView(final Context context, final ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.balloon_overlay, parent);
title = (TextView) v.findViewById(R.id.balloon_item_title);
snippet = (TextView) v.findViewById(R.id.balloon_item_snippet);
// Get ballon_close button and register its listener:
ImageView close = (ImageView) v.findViewById(R.id.balloon_close);
close.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
parent.setVisibility(GONE);
Intent intent = new Intent( );
intent.setClassName( "org.example.openstreetmap", "org.example.openstreetmap.UpdateEntityActivity" );
v.getContext().startActivity(intent);
//HERE I return from UpdateOverlayActivity.java and is where I want to modify *mOverlays*.
}
});
}
Edit: I figured out that it is not true that I return to //HERE.
You can make the
BalloonOverlayViewhold a reference to a list ofOverlayItemobject this way: