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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:59:08+00:00 2026-06-14T04:59:08+00:00

I have an inner class to create and show a simple list dialog. private

  • 0

I have an inner class to create and show a simple list dialog.

private static class DisplayListDialogFragment extends DialogFragment 
{
    List<String> list;
    OnClickListener clickListener;

    private static DisplayListDialogFragment newInstance(List<String> list, String title, OnClickListener clickListener)
    {
        DisplayListDialogFragment dldf = new DisplayListDialogFragment();
        dldf.list = (List<String>)list;
        dldf.clickListener = clickListener;
        Bundle bundle = new Bundle();
        bundle.putString("title", title);
        dldf.setArguments(bundle);
        return dldf;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState)
    {
        ArrayAdapter<String> ad = new ArrayAdapter<String>(getActivity(), R.id.simpleListItem, this.list);
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string._select_display)
               .setSingleChoiceItems(ad, 1, this.clickListener);
        return builder.create();
    }
}

The resources referenced are declared in the strings file

    <string name="_select_display">Select Display</string>

and a small file called simple_list.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/simpleListItem"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:textAppearance="?android:attr/textAppearanceMedium"
/>

The app blows up somewhere in the depths of the resource inflater at the line

return builder.create();

Stack trace is

11-12 17:21:01.664: E/AndroidRuntime(1335): android.content.res.Resources$NotFoundException: Resource ID #0x7f040052 type #0x12 is not valid
11-12 17:21:01.664: E/AndroidRuntime(1335):     at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874)
11-12 17:21:01.664: E/AndroidRuntime(1335):     at android.content.res.Resources.getLayout(Resources.java:731)
11-12 17:21:01.664: E/AndroidRuntime(1335):     at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
11-12 17:21:01.664: E/AndroidRuntime(1335):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
11-12 17:21:01.664: E/AndroidRuntime(1335):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)

Resource ID is defined in R.java as

        public static final int simpleListItem=0x7f040052

(i.e. the TextView declared in the simple_list.xml file above)

Can anybody see what’s wrong? I’m scratching my head at the moment.

Thanks

Andrew

  • 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-14T04:59:09+00:00Added an answer on June 14, 2026 at 4:59 am

    Have a look at the documentation for the specific ArrayAdapter constructor you’re calling:

    public ArrayAdapter (Context context, int textViewResourceId, List<T> objects)
    

    In particular, it explains the second parameter parameter:

    textViewResourceId – The resource ID for a layout file containing a TextView to use when instantiating views.

    In other words, you’re currently passing in a wrong ID type (that’s what the LogCat error says too). Rather than supplying a TextView ID within a layout file, you should supply the ID of the layout file. Think about it: how would Android know where to inflate your TextView from if you don’t mention the layout?

    Change creating the ArrayAdapter to:

    ArrayAdapter<String> ad = new ArrayAdapter<String>(getActivity(), R.layout.simple_list, this.list);
    

    Alternatively, pass in both the layout and TextView ID:

    ArrayAdapter<String> ad = new ArrayAdapter<String>(getActivity(), R.layout.simple_list, R.id.simpleListItem, this.list);
    

    PS: I do agree that the documentation may lead to some confusion as the meaning of the textViewResourceId parameter differs with the various constructors.

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

Sidebar

Related Questions

I have the following class structure class Top : NotifyPropertyChanged { private List<Inner> innerList;
I have a problem making an inner class that extends from JPanel to draw
I have an anonymous inner class inside another class ( SomeClass ). Both SomeClass.class.getClasses()
I have a Class called Song with Inner class Creator . Below is the
I have a class that has an inner struct/class (I have decided which yet,
I have the following code: class outer { struct inner { int var1; int
I have a class which is routing many messages into inner component instance. So
I have a client-server style design. What I have done is create a class
I have been give a jar file to use that has a static inner
Within my actor I have to create a class which sends a message to

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.