title: Access a view in a fragment layout from outside class
body: <p>I am trying to access a <code>TextView</code> from an outside class. The <code>TextView</code> is part of a <code>layout</code> inflated by a <code>fragment</code>. How do I achieve this? I cannot reference the fragment as I have 3 other fragments with different layouts.</p>
  
  <p>EDIT :</p>
  
  <p>I have this fragment where in I would like to access totalTxt :</p>
  
  <pre><code>public class FragmentCart extends Fragment {
      private TextView totalTxt;
      private ListView itemList;
  
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_cart, container, false);
          itemList = (ListView)view.findViewById(R.id.itemList);
          itemList.setAdapter(MainActivity.cart);
          return view;
      }
  </code></pre>
  
  <p>and I have this class</p>
  
  <pre><code>    public class someClass extends BaseAdapter {
           //everytime the data here is changed, I would like to update 
             the value of the totalTxt above from this class
      }
  </code></pre>