我正在寻找一种允许我从另一个类访问对象的方法;这两个类都在同一个Android活动-OpenStreeMapActivity.java中.我有:
ItemizedOverlay.java-包含我要访问和修改的对象:
private ArrayList mOverlays = new ArrayList();
BalloonOverlayView.java-是我要访问对象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*.
}
});
}
编辑:我发现返回// HERE是不正确的.