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 9050289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:36:52+00:00 2026-06-16T12:36:52+00:00

I have an activity that has a Button. When the Button is clicked it

  • 0

I have an activity that has a Button. When the Button is clicked it is supposed to open a simple Popup Window that contains a TextView and a Spinner. I have the Popup Window opening up fine. My problem is when I grab a reference to the Spinner it’s giving me a Resources$NotFoundException and saying that the resource ID is not valid.

I’m currently calling popupView.findViewById(R.layout.popup_create_workout) to try to get a reference to the spinner. I’ve also tried grabbing a reference to the parent XML layout that the Popup Window uses and invoking finViewById on it (e.g. exampleView.findViewById(R.layout.example_popup_view). I also tried plain ol’ findViewById(R.layout.example_popup_view) (which I wasn’t expecting to work). However, both of these techniques throw NullPointerExceptions either on the View ID or when I call setAdapter() on the Spinner. I’ve tried cleaning the project in Eclipse, double checked to make sure the I’m using the right reference IDs, context, etc.

What’s really throwing me for a loop is that I am able to get references to the TextView from the same XML layout and manipulate it. I’ve searched all over this site and found somewhat similar questions, but none of them were quite what I needed. I’ve also Googled everything that I could think of with no luck.

So, my qeustion is: why am I getting a Resources$NotFoundException when I try to get a reference to the spinner? I know it’s probably something easy, but I can’t seem to figure it out. Thanks in advance for your help!

Here’s the part of the activity that has to do with the spinner:

@Override
public void onClick(View v) {
    LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
    View popupView = inflater.inflate(R.layout.popup_add_goal, null);
    PopupWindow popupWindow = new PopupWindow(popupView);
    popupWindow.setWidth(240);
    popupWindow.setHeight(447);
    popupWindow.update();
    popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);

    ArrayList<String> list = new ArrayList<String>();
    list.add("Item 1");
    list.add("Item 2");
    list.add("Item 3");

    Spinner spinner = (Spinner) popupView.findViewById(R.id.goal_spinner);
    ArrayAdapter<ArrayList<String>> arrayAdapter = new ArrayAdapter<ArrayList<String>>(WorkoutActivity.context, R.id.list_content_white);
    arrayAdapter.add(list);
    spinner.setAdapter(arrayAdapter);
}

});

And the XML layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#CCff0000" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="Add goals"
    android:textColor="#ffffff"
    android:textSize="48sp" />

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:text="Search for a goal"
        android:textColor="#ffffff"
        android:textSize="40sp"
        android:gravity="center" />

    <Spinner android:id="@+id/goal_spinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ffffff" />

</LinearLayout>

And finally, the stack trace:

12-29 03:51:14.832: E/AndroidRuntime(5216): FATAL EXCEPTION: main
12-29 03:51:14.832: E/AndroidRuntime(5216): android.content.res.Resources$NotFoundException: Resource ID #0x7f09001a type #0x12 is not valid
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2144)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.content.res.Resources.getLayout(Resources.java:853)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:193)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.widget.Spinner.onMeasure(Spinner.java:439)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.View.measure(View.java:15513)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.View.measure(View.java:15513)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.View.measure(View.java:15513)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.Choreographer.doFrame(Choreographer.java:532)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.os.Handler.handleCallback(Handler.java:725)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.os.Handler.dispatchMessage(Handler.java:92)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.os.Looper.loop(Looper.java:137)
12-29 03:51:14.832: E/AndroidRuntime(5216): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-29 03:51:14.832: E/AndroidRuntime(5216): at java.lang.reflect.Method.invokeNative(Native Method)
12-29 03:51:14.832: E/AndroidRuntime(5216): at java.lang.reflect.Method.invoke(Method.java:511)
12-29 03:51:14.832: E/AndroidRuntime(5216): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-29 03:51:14.832: E/AndroidRuntime(5216): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-29 03:51:14.832: E/AndroidRuntime(5216): at dalvik.system.NativeStart.main(Native Method)

Here’s the layout that contains list_content_white:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<TextView
android:id="@+id/list_content_white"
android:textColor="#ffffff"
android:textSize="30sp"
android:textStyle="bold"
android:layout_margin="8dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />

</LinearLayout>
  • 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-16T12:36:53+00:00Added an answer on June 16, 2026 at 12:36 pm

    I’m not sure what is causing the exception, but it could be this. Change:

    ArrayAdapter<ArrayList<String>> arrayAdapter = new ArrayAdapter<ArrayList<String>>(WorkoutActivity.context, R.id.list_content_white);
    arrayAdapter.add(list);
    

    To:

    ArrayAdapter<String> arrayAdapter = 
        new ArrayAdapter<String>(WorkoutActivity.this, R.id.list_content_white, list);
    //                        This is wrong, see below  ^^^^
    

    The ArrayAdapter already expects an ArrayList, you simply need to provide the ArrayList’s subtype.


    The root problem
    There is a slight danger in naming your layout file the same name as a View’s id… You have found it. You want to use R.layout.list_content_white not R.id.list_content_white while initializing your ArrayAdapter.

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

Sidebar

Related Questions

I have a widget it has a button which starts another activity and that
I have a home activity ActivityA, which has button that creates an intent, sets
Here's the scenario I have an activity(A) which has a button and textview. I
I have three activities in my app: .OpeningScene: An opening activity that contains my
I have an activity with a single TextView (tv1) and a button that, when
Here is the short version. I have a Bonus Activity that has 25 image
I have a application that has an activity that shows message logs. The thing
I have an Activity class which has an attribute that references an AsyncTask instance
Assume that we have 3 different activities. Each activity has its own XML file
I have an activity that shows some TextView s and EditText s, as well

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.