<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="10dp" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="@string/beginatStr" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#000000" android:textSize="8sp" > </TextView> <TextView android:id="@+id/calloutBeginsAt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/textView1" android:layout_toRightOf="@+id/textView1" android:text="TextView" android:textColor="#000000" android:textSize="8sp" > </TextView> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/textView1" android:layout_marginTop="16dp" android:text="@string/calloutEndsAt" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#000000" android:textSize="8sp" > </TextView> <TextView android:id="@+id/calloutEndsAt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/textView2" android:layout_alignLeft="@+id/calloutBeginsAt" android:text="TextView" android:textColor="#000000" android:textSize="8sp" > </TextView> <TextView android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/textView2" android:layout_marginTop="18dp" android:text="@string/calloutLoc" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#000000" android:textSize="8sp" > </TextView> <TextView android:id="@+id/calloutLoc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/textView4" android:layout_alignLeft="@+id/calloutEndsAt" android:text="TextView" android:textColor="#000000" android:textSize="8sp" > </TextView> </RelativeLayout>
Callout callout = map.getCallout(); callout.setCoordinates((Point) event.getGeometry()); callout.setTitle(event.getName()); View calloutView = inflater.inflate(R.layout.callout, null); //Access the internal Textviews insdie the calloutView. TextView begins = (TextView) calloutView.findViewById(R.id.calloutBeginsAt); TextView ends = (TextView) calloutView.findViewById(R.id.calloutEndsAt); TextView loc = (TextView) calloutView.findViewById(R.id.calloutLoc); //Set Up values begins.setText(event.getNextOccurance().getBegin().getDay() + ", " + event.getNextOccurance().getBegin().getHours() + ":" + event.getNextOccurance().getBegin().getMinutes()); ends.setText(event.getNextOccurance().getEnd().getDay() + ", " + event.getNextOccurance().getEnd().getHours() + ":" + event.getNextOccurance().getEnd().getMinutes()); loc.setText(event.getAddress()); begins.setEnabled(true); ends.setEnabled(true); loc.setEnabled(true); //Set the content, show the view callout.setContent(calloutView); callout.show();
<?xml version="1.0" encoding="utf-8"?> <resources> <calloutViewStyle titleTextColor="#000000" titleTextSize="10" titleTextStyle="0" titleTextTypeFace="0" backgroundColor="#ffffff" backgroundAlpha="255" frameColor="#000000" flat="true" anchor="5" /> </resources>
final Context ctx = this; final LayoutInflater inflater = this.getLayoutInflater(); map.setOnSingleTapListener(new OnSingleTapListener() { private static final long serialVersionUID = 5173550791541184304L; public void onSingleTap(float x, float y) { Toast.makeText( ctx, "onSingleTap(" + String.valueOf(x) + " , " + String.valueOf(y) + ")", Toast.LENGTH_SHORT ).show(); Point screenPoint = new Point(x, y); Point mapPoint = map.toMapPoint(screenPoint); Callout callout = map.getCallout(); callout.setCoordinates(mapPoint); //callout.setCoordinates((Point) event.getGeometry()); //callout.setTitle(event.getName()); View calloutView = inflater.inflate(R.layout.callout, null); //Access the internal Textviews inside the calloutView. TextView begins = (TextView) calloutView.findViewById(R.id.calloutBeginsAt); TextView ends = (TextView) calloutView.findViewById(R.id.calloutEndsAt); TextView loc = (TextView) calloutView.findViewById(R.id.calloutLoc); //Set Up values begins.setText("begins"); ends.setText("ends"); loc.setText("loc"); begins.setEnabled(true); ends.setEnabled(true); loc.setEnabled(true); //Set the content, show the view callout.setContent(calloutView); callout.setStyle(R.xml.calloutstyle); callout.refresh(); callout.show(); } } );