adickel

Callout View and Text Views (Android API)

Discussion created by adickel on Dec 9, 2011
Latest reply on Feb 29, 2012 by stephen_quan
I have a little program and im trying to populate a callout with feature data, I have a custom callout view style and a custom view that I'm inserting into my callout.  In the view, there are 6 TextViews and 3 of them are labels and 3 I want to be labeled with data from java.  I use view1.setText("MyText")  after getting the Ids from the callout view. 

The problem is none of the text from java is showing up on the callout.   The static text labels show up fine and my calloutViewStyle works fine as well.  I'm not sure what to do and it'd be great if I could get this working soon. 

Also, Is there some way to populate a call out with a "Graphic" object and its attribute names/table?

Heres the custom view I am inserting into my callout


<?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>


Here is the java portion where I am setting up the values.  Thanks for all the help in advance!

 
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(); 

Outcomes