title: Change TextView value from Non-Activity class
body: <p>I'm trying to setText a new value to my TextView from a non activity class by inflating the layout where the textview is, but I'm still unsuccessful though I'm able to getText the current value of the TV. Here's the code:</p>
  
  <pre><code>LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(mContext.LAYOUT_INFLATER_SERVICE);
  View view = mInflater.inflate(R.layout.target_details, null);
  
  TextView val = (TextView) view.findViewById(R.id.val);
  </code></pre>
  
  <p>Not sure if I'm doing it properly.</p>
  
  <p>UPDATE:
  I used Kay's answer with added code below. It's now working.</p>
  
  <pre><code>((Activity)mContext).runOnUiThread(new Runnable(){
          @Override
          public void run(){
              //settext here
          }
      });
  </code></pre>