title: Cannot resolve method .runOnUiThread
body: <p>I found <a href="https://stackoverflow.com/questions/8665676/how-to-use-notifydatasetchanged-in-thread">this</a> example here on how to use the <code>runOnUiThread</code> method, but I don't understand how to use it.</p>
  
  <p>I setup the list adapter in my main activity</p>
  
  <pre><code>    // Set a gobal reference to the list adapter and the list respectivly 
  
      ListAdapter listAdapter;
      static ArrayList&lt;String&gt; list;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // some code
  
          adapter = new ListAdapter(getActivity(), R.layout.item_layout, list);
          listView.setAdapter(adapter);
  
          // some code
  
      }
  </code></pre>
  
  <p>I have the list adapter here calling a service handler class</p>
  
  <pre><code>public class ListAdapter {
  
      // some code
  
      ServiceHandler sh = new ServiceHandler();
  
      sh.run();
  }
  </code></pre>
  
  <p>Here is <code>.run()</code> method in <code>ServiceHandler</code> class where I updated the list and the list adapter</p>
  
  <pre><code>public void run(Adapter listAdapter, ArrayList&lt;String&gt; list){
  
      // some code
  
      list[0] = "foo";
      listAdapter.notifyDataSetChanged;
  }
  </code></pre>
  
  <p>But I get this error in run time</p>
  
  <blockquote>
    <p>Only the original thread that created a view hierarchy can touch its views.</p>
  </blockquote>
  
  <p>So I try to solve the error with <code>.runOnUiThread</code></p>
  
  <p>So here is <code>.run()</code> method in <code>ServiceHandler</code> class again, with <code>runOnUiThread</code></p>
  
  <pre><code>public void run(Adapter listAdapter, ArrayList&lt;String&gt; list){
  
      // some code
  
      runOnUiThread(new Runnable() {
          @Override
          public void run() {
  
              list[0] = "foo";
              listAdapter.notifyDataSetChanged;
      });
  }
  </code></pre>
  
  <p>But I get </p>
  
  <blockquote>
    <p>Cannot resolve method 'runOnUiThread(anonymous Java.lang.runnable)'</p>
  </blockquote>