I simply have 2 tabs and used Experience – Multiple Android Activities in a TabActivity as reference.
My class Architecture is like this:
MainActivity extends TabActivity
1.TabGroup1Activity extends TabGroupActivity (TabGroupActivity-class implemented from above reference)
1.i. Tab1Activity extends MapActivity (which has multiple marker)
2.TabGroup2Activity extends TabGroupActivity
2.i. Tab2Activity
In second tab (Tab2Activity) i show the google map which has multiple markers. On Taping the marker i want to start new Activity under same tab without loosing tab which as at bottom.
Here is the ItemizedOverlayItem class:
MapItemizedOverlay.java
public class MapItemizedOverlay extends ItemizedOverlay<OverlayItem> {
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
private Context mContext;
public InformationItemizedOverlay(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
mContext = context;
}
public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
populate();
}
@Override
protected OverlayItem createItem(int i) {
return mOverlays.get(i);
}
@Override
public int size() {
return mOverlays.size();
}
@Override
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
//what code i have to write to start new activity without loosing tabs at bottom
}
}
I know i have to write the following code to start new activity under same tab but for above example i can not write getParent().
Intent in = new Intent(getParent(), TestActivity.class);
TabGroupActivity parentActivity = (TabGroupActivity) getParent();
parentActivity.startChildActivity("in", in);
How do i solve this problem ??
simply pass the parent as agrgument from where you are calling “InformationItemizedOverlay”.
Might be you are calling like below from some where in your code.
InformationItemizedOverlay informationItemizedOverlay = new InformationItemizedOverlay(drawable,context);
so change it as below
also change the constructor of “InformationItemizedOverlay” as appropriately…..