title: Textviews in a Fragment layout don't change when calling SetText()
body: <p>My application (min level 13) is an Activity that uses tabs in the action bar to manage a couple fragments, very similar to <a href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.html" rel="noreferrer">this</a>.</p>
  
  <p>Now, the activity starts a service which does continuous computation and returns values which I would like to display in the Fragments. The Activity - Service communication is implemented through broadcast receivers and the Activity shuffles the data off to the appropriate Fragment. </p>
  
  <p>Everything seems setup correctly and the data makes it to the Fragment update method but when I try to display the new values in textviews, the new values are never displayed.</p>
  
  <p>The code to change the textviews:</p>
  
  <pre><code>    TextView tv = (TextView) getView().findViewById(R.id.fieldNavGpsTime);
      Double doub = input.getDoubleExtra("com.some.thing.GPS_TIME", -1.0);
      tv.setText(doub.toString());
  </code></pre>
  
  <p>The code to call the Fragments update methods from the broadcast receiver in the Activity:</p>
  
  <pre><code>    NavigationGuiFragment navfrag = (NavigationGuiFragment) getFragmentManager().findFragmentByTag("navigation");
      if (navfrag != null &amp;&amp; navfrag.isResumed())
          navfrag.UpdateNavUI(intent);
  </code></pre>
  
  <p>I've noticed that isVisible() doesn't seem to ever return true, but I'm not sure what it means or how to change it.</p>
  
  <p>Additionally, I can't seem to add an imageview to a Fragment programmatically. Here's the code (which resides in onActivityCreated()):</p>
  
  <pre><code>    this.compass = new BasicCompass(getActivity());
      LinearLayout ll = (LinearLayout) getView().findViewById(R.id.nav_hrztl_lnly);
      ll.addView(this.compass);
  </code></pre>
  
  <p>The BasicCompass constructor takes a Context, admittedly I'm not completely sure what I'm passing in is correct.</p>
  
  <p>The code for this was more or less taken from a working Activity and dropped into a Fragment to allow for tabs. I'm open to suggestion in regards to changing the structure of the code.</p>
  
  <p>Thanks for any help.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The xml layout of the Fragment:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/nav_hrztl_lnly"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="horizontal"
  android:focusable="true"
  android:focusableInTouchMode="true"
  android:baselineAligned="false" &gt;
  
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="600dp"
      android:layout_height="fill_parent"
      android:orientation="vertical"
      android:focusable="true"
      android:focusableInTouchMode="true" &gt;
  
      &lt;EditText
          android:id="@+id/labelNavGpsTime"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/gps_time" /&gt;
  
      &lt;EditText
          android:id="@+id/fieldNavGpsTime"
          style="@style/field_padding"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:hint="@string/zero_3_digits"
          android:inputType="numberDecimal" /&gt;
  
      &lt;EditText
          android:id="@+id/labelNavLatitude"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/latitude" /&gt;
  
      &lt;EditText
          android:id="@+id/fieldNavLatitude"
          style="@style/field_padding"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:hint="@string/zero_6_digits"
          android:inputType="numberDecimal" /&gt;
  
      &lt;EditText
          android:id="@+id/labelNavLongitude"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/longitude" /&gt;
  
      &lt;EditText
          android:id="@+id/fieldNavLongitude"
          style="@style/field_padding"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:hint="@string/zero_6_digits"
          android:inputType="numberDecimal" /&gt;
  
      &lt;EditText
          android:id="@+id/labelNavAltitude"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/altitude" /&gt;
  
      &lt;EditText
          android:id="@+id/fieldNavAltitude"
          style="@style/field_padding"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:hint="@string/zero_3_digits"
          android:inputType="numberDecimal" /&gt;
  
      &lt;EditText
          android:id="@+id/labelNavRoll"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/roll" /&gt;
  
      &lt;EditText
          android:id="@+id/fieldNavRoll"
          style="@style/field_padding"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:hint="@string/zero_6_digits"
          android:inputType="numberDecimal" /&gt;
  
      &lt;EditText
          android:id="@+id/labelNavPitch"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/pitch" /&gt;
  
      &lt;EditText
          android:id="@+id/fieldNavPitch"
          style="@style/field_padding"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:hint="@string/zero_6_digits"
          android:inputType="numberDecimal" /&gt;
  
      &lt;EditText
          android:id="@+id/labelNavAzimuth"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/azimuth_heading" /&gt;
  
      &lt;EditText
          android:id="@+id/fieldNavAzimuth"
          style="@style/field_padding"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:hint="@string/zero_6_digits"
          android:inputType="numberDecimal" /&gt;
  
      &lt;LinearLayout
          android:id="@+id/nav_rdbtn_lnly"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" &gt;
  
          &lt;RadioButton
              android:id="@+id/rdbtnNavGpsAvailability"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/gps_avail" /&gt;
  
          &lt;RadioButton
              android:id="@+id/rdbtnNavZuptStatus"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/zupt_stat" /&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>And the Fragment that uses it:</p>
  
  <pre><code>public class NavigationGuiFragment extends Fragment
  {
  private RadioButton gpsRdBtn;
  private RadioButton zuptRdBtn;
  private BasicCompass compass;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
  {
      View fragview =  inflater.inflate(R.layout.navigation_fragment, container, false);
  
      // sets up the rose image that serves as a compass in the GUI
      this.compass = new BasicCompass(getActivity());
      LinearLayout ll = (LinearLayout) fragview.findViewById(R.id.nav_hrztl_lnly);
      ll.addView(this.compass);
  
      return fragview;
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) 
  {
      super.onActivityCreated(savedInstanceState);
      getActivity().setContentView(R.layout.navigation_fragment);
  
      //Initialize the radio buttons
      gpsRdBtn = (RadioButton) getView().findViewById(R.id.rdbtnNavGpsAvailability);
      gpsRdBtn.setChecked(false);
  
      zuptRdBtn = (RadioButton) getView().findViewById(R.id.rdbtnNavZuptStatus);
      zuptRdBtn.setChecked(false);    
  }
  
  @Override
  public void onResume() 
  {
      super.onResume();
  
      if (!IsMyServiceRunning())
      {
          gpsRdBtn.setChecked(false);
          zuptRdBtn.setChecked(false);
      }
  }
  
  public void UpdateNavUI(Intent input)
  {       
      TextView tv = (TextView) getView().findViewById(R.id.fieldNavGpsTime);
      Double doub = input.getDoubleExtra("com.some.thing.GPS_TIME", -1.0);
      tv.setText(doub.toString());
  
      tv = (TextView) getView().findViewById(R.id.fieldNavLatitude);
      doub = input.getDoubleExtra("com.some.thing.LATITUDE", 100000.0);
      tv.setText(doub.toString());
  
      tv = (TextView) getView().findViewById(R.id.fieldNavLongitude);
      doub = input.getDoubleExtra("com.some.thing.LONGITUDE", 100000.0);
      tv.setText(doub.toString());
  
      tv = (TextView) getView().findViewById(R.id.fieldNavAltitude);
      doub = input.getDoubleExtra("com.some.thing.ALTITUDE", -1.0);
      tv.setText(doub.toString());
  
      tv = (TextView) getView().findViewById(R.id.fieldNavRoll);
      doub = input.getDoubleExtra("com.some.androidndk.ROLL", 361.0);
      tv.setText(doub.toString());
  
      tv = (TextView) getView().findViewById(R.id.fieldNavPitch);
      doub = input.getDoubleExtra("com.some.thing.PITCH", 361.0);
      tv.setText(doub.toString());
  
      tv = (TextView) getView().findViewById(R.id.fieldNavAzimuth);
      doub = input.getDoubleExtra("com.some.thing.AZIMUTH", 361.0);
      tv.setText(doub.toString());
  
      this.compass.SetDirection(doub.floatValue());
  
      boolean bool = input.getBooleanExtra("com.some.thing.ZUPT_STATUS", false);
      zuptRdBtn.setChecked(bool);
  
      UpdateGpsIndicator(input);
  }
  
  public void UpdateGpsIndicator(Intent input)
  {
      boolean bool = input.getBooleanExtra("com.some.thing.GPS_ON", false);
      gpsRdBtn.setChecked(bool);
  }
  
  private boolean IsMyServiceRunning()
  {
      ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
      for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
      {
          if ("com.some.thing.Service".equals(service.service.getClassName())) 
              return true;
      }
  
      return false;
  }
  </code></pre>
  
  <p>}</p>