title: update textview in fragment constantly
body: <p>I want to periodically update a fragment textview with the value from a main activity. I have used Interface method but that doesnt let the textview update periodically right?</p>
  
  <p>Activity</p>
  
  <pre><code>public class main2 extends ActionBarActivity implements readingdata{
  
    Button Loge,read;
    static int count=2;
  
     @Override
     protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main2);
      Loge=(Button)findViewById(R.id.btnlog);
      FragmentTransaction ft = getFragmentManager().beginTransaction();
      Fragment frag = new UI();
      ft.add(R.id.fragment, frag, "UIfrag");
      ft.addToBackStack(null);
      ft.commit();
  
      Timer mytime=new Timer();
          mytime.scheduleAtFixedRate(new TimerTask() {
              @Override
              public void run() {
                        count=count+1;
                         Log.e("working", "updating");
                         passData();
  
  
          }
      }, 1 * 05 * 500, 1 * 10 * 500);
  
     @Override
       public int passData() {
            return count;
  
       }
  
  
  }
  </code></pre>
  
  <p>Fragment</p>
  
  <pre><code>public class UI extends Fragment{
  
      TextView txttemp,txthumid;
      readingdata datais;
        public static int res=0;
       String mydata="2";
           @Nullable
         @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,                  Bundle savedInstanceState) {
                                                                                                      View rootview=inflater.inflate(R.layout.uilayout,container,false);
       txttemp=(TextView)rootview.findViewById(R.id.tvhumid);
      txthumid=(TextView)rootview.findViewById(R.id.tvtemp);
      Log.e("working", "oncreatefrag");
      Log.e("res changedornot",String.valueOf(res));
      txthumid.setText(String.valueOf(res));
      return rootview;
  }
  
  @Override
     public void onAttach(Activity activity) {
      super.onAttach(activity);
      datais=(readingdata)activity;
      res=datais.passData();
    }     }
  
  
        interface readingdata
         {
           public int passData();
          }
  </code></pre>