title: android.view.ViewRootImpl$CalledFromWrongThreadException:Only the original thread that created a view hierarchy can touch its views
body: <p>i am currently facing this error. I have tried many ways to try and solve it but to no avail. Please point out to me where went wrong and how can i solve it. Thanks.</p>
  
  <p>The error message:</p>
  
  <pre><code>                  android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
  </code></pre>
  
  <p>Here is the java class:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>package com.uploadtodatabasevts;
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ListView;
  import android.widget.TextView;
  
  import com.amazonaws.auth.CognitoCachingCredentialsProvider;
  import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper;
  import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBQueryExpression;
  import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.PaginatedQueryList;
  import com.amazonaws.regions.Regions;
  import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class Advisor extends AppCompatActivity implements AdapterView.OnItemClickListener {
  
      List&lt;Outfit&gt; outfitList;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_advisor);
  
          Intent intent = getIntent();
          final String results = intent.getStringExtra("results");
  
          final TextView itemOneID = (TextView)findViewById(R.id.txtViewItemOneID);
          final TextView itemOneDetail = (TextView)findViewById(R.id.txtViewItemOneDetail);
          final TextView itemOnePrice = (TextView)findViewById(R.id.txtViewItemOnePrice);
  
  
          ListView listView = (ListView)findViewById(R.id.listView);
          outfitList = new ArrayList&lt;Outfit&gt;();
          Adapter adapter = new Adapter(this, outfitList);
          listView.setAdapter(adapter);
          listView.setOnItemClickListener(this);
  
          final AmazonDynamoDBClient ddbClient = new AmazonDynamoDBClient(credentialsProvider);
          final DynamoDBMapper mapper = new DynamoDBMapper(ddbClient);
  
         // final Outfit outfitToFind = new Outfit();
        //  outfitToFind.setItemOne_id("VT0056");
  
  
          Runnable runnable = new Runnable() {
              public void run() {
                  //DynamoDB calls go here
  
                  Outfit selectedOutfit = mapper.load(Outfit.class, "22");
  
                  selectedOutfit.getItemOne_id();
                  selectedOutfit.getItemOne_detail();
                  selectedOutfit.getItemOne_price();
  
                  itemOneID.setText(selectedOutfit.getItemOne_id());
                  itemOneDetail.setText(selectedOutfit.getItemOne_detail());
                  itemOnePrice.setText(selectedOutfit.getItemOne_price());
                  /*
                  DynamoDBQueryExpression queryExpression = new DynamoDBQueryExpression()
                          .withHashKeyValues(outfitToFind)
                          .withConsistentRead(false);
  
                  PaginatedQueryList&lt;Outfit&gt; result = mapper.query(Outfit.class, queryExpression);
                  result.
                  */
              }
          };
          Thread mythread = new Thread(runnable);
          mythread.start();
  
  
  
      }
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
  
      }
  }</code></pre>
  </div>
  </div>
  </p>