title: ArrayAdapter: You must supply a resource ID for a TextView- Android Studio
body: <p>I am trying to build a currency converter using an ArrayAdapter. But I get this error! Does anyone know how to fix that? <strong><em>I have checked other posts here but nothing seems to work.</em></strong> I was following a tutorial on youtube but the dev didnt have this problem. A friend of mine did the same tutorial and we have the same code but her project works fine...dunno whats wrong with it</p>
  
  <pre><code>01-03 20:05:20.242 5183-5183/? E/ArrayAdapter: You must supply a resource ID for a TextView
  01-03 20:05:20.243 5183-5183/? D/AndroidRuntime: Shutting down VM
  01-03 20:05:20.245 5183-5183/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.android.example.currencyconverter2, PID: 5183
                                                   java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
                                                       at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:393)
                                                       at android.widget.ArrayAdapter.getView(ArrayAdapter.java:369)
                                                       at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:194)
                                                       at android.widget.Spinner.onMeasure(Spinner.java:580)
                                                       at android.support.v7.widget.AppCompatSpinner.onMeasure(AppCompatSpinner.java:418)
                                                       at android.view.View.measure(View.java:18788)
                                                       at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
                                                       at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
                                                       at android.view.View.measure(View.java:18788)
                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                       at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                                                       at android.view.View.measure(View.java:18788)
                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                                                       at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
                                                       at android.view.View.measure(View.java:18788)
                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                       at android.view.View.measure(View.java:18788)
                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                                                       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                                                       at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                                                       at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                                                       at android.view.View.measure(View.java:18788)
                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                       at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
                                                       at android.view.View.measure(View.java:18788)
                                                       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
                                                       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
                                                       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
                                                       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
                                                       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
                                                       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
                                                       at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                       at android.view.Choreographer.doFrame(Choreographer.java:606)
                                                       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                       at android.os.Handler.handleCallback(Handler.java:739)
                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                       at android.os.Looper.loop(Looper.java:148)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                    Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
                                                       at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:386)
                                                       at android.widget.ArrayAdapter.getView(ArrayAdapter.java:369) 
                                                       at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:194) 
                                                       at android.widget.Spinner.onMeasure(Spinner.java:580) 
                                                       at android.support.v7.widget.AppCompatSpinner.onMeasure(AppCompatSpinner.java:418) 
                                                       at android.view.View.measure(View.java:18788) 
                                                       at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) 
                                                       at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) 
                                                       at android.view.View.measure(View.java:18788) 
                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951) 
                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) 
                                                       at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) 
                                                       at android.view.View.measure(View.java:18788) 
                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951) 
                                                       at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391) 
                                                       at android.view.View.measure(View.java:18788) 
                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951) 
                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) 
                                                       at android.view.View.measure(View.java:18788) 
                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951) 
                                                       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465) 
                                                       at android.widget.LinearLayout.measureVertical(LinearLayout.java:748) 
                                                       at android.widget.LinearLayout.onMeasure(LinearLayout.java:630) 
                                                       at android.view.View.measure(View.java:18788) 
                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951) 
                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) 
                                                       at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643) 
                                                       at android.view.View.measure(View.java:18788) 
                                                       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100) 
                                                       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216) 
                                                       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452) 
                                                       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107) 
                                                       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013) 
                                                       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) 
                                                       at android.view.Choreographer.doCallbacks(Choreographer.java:670) 
                                                       at android.view.Choreographer.doFrame(Choreographer.java:606) 
                                                       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) 
                                                       at android.os.Handler.handleCallback(Handler.java:739) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                       at android.os.Looper.loop(Looper.java:148) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  </code></pre>
  
  <p>my code:</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Spinner;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.androidquery.AQuery;
  import com.androidquery.callback.AjaxCallback;
  import com.androidquery.callback.AjaxStatus;
  
  import org.json.JSONException;
  import org.json.JSONObject;
  
  public class MainActivity extends AppCompatActivity {
  
  private EditText InputCurrency;
  private Spinner ConvertFrom;
  private Spinner ConvertToC;
  private Button btnConvert;
  private TextView CFtextView;
  private TextView CTtextView;
  private String fixer_url ="http://api.fixer.io/latest?symbols="; //USD,GBP
  private AQuery aq;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      InputCurrency =(EditText) findViewById(R.id.InputEditText);
      ConvertFrom = (Spinner)findViewById(R.id.fspinner);
      ConvertToC = (Spinner)findViewById(R.id.Tspinner);
      btnConvert = (Button)findViewById(R.id.btnConvert);
      CFtextView = (TextView)findViewById(R.id.CFtextView);
      CTtextView = (TextView)findViewById(R.id.CTtextView);
      aq = new AQuery(this);
  
  
              // Create an ArrayAdapter using the string array and a default spinner layout
              ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this,
                      R.array.currencies_array,     android.R.layout.activity_list_item);
  // Specify the layout to use when the list of choices appears
                  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  // Apply the adapter to the spinner
                  ConvertFrom.setAdapter(adapter);
                  ConvertToC.setAdapter(adapter);
  </code></pre>
  
  <p>gradle file:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 23
      buildToolsVersion "24.0.3"
  
  defaultConfig {
      applicationId "com.android.example.currencyconverter2"
      minSdkVersion 16
      targetSdkVersion 23
      versionCode 1
      versionName "1.0"
  }
  buildTypes {
      release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
  }
  }
  
  dependencies {
      compile fileTree(include: ['*.jar'], dir: 'libs')
      testCompile 'junit:junit:4.12'
      compile 'com.android.support:appcompat-v7:23.4.0'
      compile files('libs/android-query-full.0.26.8.jar')
  }
  </code></pre>