Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8131295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:03:28+00:00 2026-06-06T09:03:28+00:00

I am trying to populate a spinner, but am getting an error. Here is

  • 0

I am trying to populate a spinner, but am getting an error. Here is my code…

private ArrayList<String> ctRatioList = new ArrayList<String>();
private ArrayList<String> rVoltsList = new ArrayList<String>();

@Override
public void onCreate( Bundle savedInstanceState ) {
    super.onCreate( savedInstanceState );
    setContentView( R.layout.parameters );

    ctRatioList.add( "800:5" );
    ctRatioList.add( "1200:5" );
    ctRatioList.add( "1600:5" );
    ctRatioList.add( "2000:5" );
    ctRatioList.add( "2500:5" );
    ctRatioList.add( "3000:5" );
    ctRatioList.add( "3500:5" );
    ctRatioList.add( "4000:5" );
    ctRatioList.add( "4500:5" );        
    Spinner ctRatioSpinner = (Spinner) findViewById( R.id.ctRatioSpinner );
    ArrayAdapter<String> ctRatioAdapter = new ArrayAdapter<String>( this, R.layout.parameters, ctRatioList );
    ctRatioSpinner.setAdapter( ctRatioAdapter );


    for( double i = 0; i < 10 ; i+=0.1 ) {
        rVoltsList.add( Double.toString( i ) );
    }
    Spinner rVoltsSpinner = (Spinner) findViewById( R.id.recloseVoltsSpinner );
    ArrayAdapter<String> rVoltsAdapter = new ArrayAdapter<String>( this, R.layout.parameters, rVoltsList );
    rVoltsSpinner.setAdapter( rVoltsAdapter );
}

This is my LogCat…

06-26 09:39:30.235: W/dalvikvm(7711): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-26 09:39:30.259: E/AndroidRuntime(7711): FATAL EXCEPTION: main
06-26 09:39:30.259: E/AndroidRuntime(7711): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:347)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:192)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.View.measure(View.java:8313)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.TableRow.getColumnsWidths(TableRow.java:308)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.TableLayout.findLargestCells(TableLayout.java:500)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.TableLayout.measureVertical(TableLayout.java:465)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.TableLayout.onMeasure(TableLayout.java:431)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.View.measure(View.java:8313)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1074)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.ScrollView.onMeasure(ScrollView.java:296)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.View.measure(View.java:8313)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.View.measure(View.java:8313)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.View.measure(View.java:8313)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.View.measure(View.java:8313)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.View.measure(View.java:8313)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.os.Looper.loop(Looper.java:130)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.app.ActivityThread.main(ActivityThread.java:3683)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at java.lang.reflect.Method.invokeNative(Native Method)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at java.lang.reflect.Method.invoke(Method.java:507)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-26 09:39:30.259: E/AndroidRuntime(7711):     at dalvik.system.NativeStart.main(Native Method)
06-26 09:39:30.259: E/AndroidRuntime(7711): Caused by: java.lang.ClassCastException: android.widget.LinearLayout
06-26 09:39:30.259: E/AndroidRuntime(7711):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:340)
06-26 09:39:30.259: E/AndroidRuntime(7711):     ... 36 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:03:29+00:00Added an answer on June 6, 2026 at 9:03 am

    The exception says “ArrayAdapter requires the resource ID to be a TextView”

    In this call the resource R.layout.parameters isn’t a text view, it is a complete layout:

    ArrayAdapter<String> ctRatioAdapter = new ArrayAdapter<String>( this, R.layout.parameters, ctRatioList );
    

    You should use something like android.R.layout.simple_spinner_item. See the Spinner Tutorial in the Android documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to populate a ListView ....but I cant add 2 string values
Hi i am trying to a populate a spinner with strings using arrayadapter.but i
iam trying to populate the HyperlinkButton.NavigateUri Property with a string from the properties... But
I'm trying to populate a listview from another class, but I'm geting this error:
I'm trying to populate the spinner, but the application crashes on spiner.setAdapter(adapter)... final Context
I have a spinner and I am trying to populate it manually in the
I trying to populate the dropdown list when page was loaded.But it is not
I am trying to populate variables in the Report Custom Code area (or even
Hello I'm trying to populate a mschart from sql but even if the series
im trying to populate my listview beneath my tab function but for some reason

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.