-2

I am new to android and I need a small help. I am developing an application much like google maps. I am able to create a map interface and display markers along with on tap(int index) method to show the text when clicked on the markers. Now I need to start another activity when the text (which comes after clicking on the marker by using ontap method) is clicked much like how we see reviews and other things about a location in google map. I searched and found an implementation of some balloonitemized overlay class.

My question is whether there is another way to do the same thing without using this balloonitemized class?

public class HelloItemizedOverlay extends ItemizedOverlay<OverlayItem>{
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
private Context mContext;

public HelloItemizedOverlay(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);
    AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
    dialog.setTitle(item.getTitle());
    dialog.setMessage(item.getSnippet());
    dialog.show();
    return true;
}
}
user2188951
  • 1
  • 1
  • 3

1 Answers1

0

You could do something like this:

LayoutInflater cancelInflater = getLayoutInflater();
dialogView = cancelInflater.inflate(R.layout.DIALOG, null);
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setView(dialogView);
dialogView.setOnClickListener(mViewClickListener);

You'll need to create a layout file for your dialog, R.layout.DIALOG

You can then findViewById() for your separate widgets in your layout and populate them accordingly.

Then create an onClickListener to do whatever needs to be done when the dialog is clicked.

ElefantPhace
  • 3,806
  • 3
  • 20
  • 36