title: How to Refresh or Update Fragment UI
body: <p>I am Passing Data through Activity to Fragment using Bundle, Bundle getting it's value from counter, Counter updating it's value base on Thread. </p>
  
  <p>I was able to get data in Fragment but UI of Fragment only Updating on Fragment Transaction, so question is</p>
  
  <blockquote>
    <p><strong>how can i update fragment Ui at Real time</strong></p>
  </blockquote>
  
  <p>Code As Follows:</p>
  
  <pre><code>    int i=0;
      Sbundle = new Bundle();
      thread = new Thread() {
  
  
          @Override
          public void run() {
              try {
                  while (!thread.isInterrupted()) {
                      Thread.sleep(1000);
                      runOnUiThread(new Runnable() {
                          @Override
                          public void run() {
                              i++;
                              Sbundle.putString("speed", String.valueOf(i) );
  
  
                          }
                      });
                  }
              } catch (InterruptedException e) {
              }
          }
      };
      thread.start();
  
  }
  </code></pre>
  
  <p>Fragment Transaction onclick :</p>
  
  <pre><code> public void onClick(View v) {
  
  
  
                 speedFragment = new SpeedFragment();
                  speedFragment.setArguments(Sbundle);
  
  
                  RoboActivity activity = MainActivity.this;
                  if (!isFinishing() &amp;&amp; !isDestroyed()) {
  
                      FragmentTransaction ft = activity.getFragmentManager()
                              .beginTransaction();
                      ft.replace(R.id.fragment_container, speedFragment);
                      ft.detach(speedFragment).attach(speedFragment).commit();
                  }
  
  
      }
  </code></pre>
  
  <p>at fragment side:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      Bundle bundle = this.getArguments();
      mySpeed = bundle.getString("speed");
  
          }
  </code></pre>