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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:52:10+00:00 2026-06-10T05:52:10+00:00

I am creating a custom AlertDialog with AlertDialog.Builder. However, I am unable to get

  • 0

I am creating a custom AlertDialog with AlertDialog.Builder. However, I am unable to get my spinner to work within the AlertDialog. Whenever i click the spinner, I get an error that says

android.view.WindowManager BadTokenException: Unable to add window--token null
is not for an application

Initially, i thought this was due to my custom adapter but this isn’t the cause of the error. I don’t understand why this is happening. I have coded my spinners this way for years and have never had this problem. Here is my code. Thanks in advance.

public void openCustomDialog(){
    AlertDialog.Builder customDialog= new AlertDialog.Builder(Portfolio.this);
    customDialog.setTitle("Create Portfolio");

    LayoutInflater layoutInflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view=layoutInflater.inflate(R.layout.createdialog,null);

    EditText enterportfolioname = (EditText)view.findViewById(R.id.enterportfolioname);
    Spinner denominationselection = (Spinner)view.findViewById(R.id.denomination);
    ArrayAdapter<String> adaptercreatetype;
    createdenominationsarray = getResources().getStringArray(R.array.createdenominations);    
    adaptercreatetype = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,createdenominationsarray){
            @Override
            public View getDropDownView(int position, View convertView, ViewGroup parent)
            {
                View v = null;

                // If this is the initial dummy entry, make it hidden
                if (position == 0) {
                    TextView tv = new TextView(getContext());
                    tv.setHeight(0);
                    tv.setVisibility(View.GONE);
                    v = tv;
                }
                else {
                    // Pass convertView as null to prevent reuse of special case views
                    v = super.getDropDownView(position, null, parent);
                }

                // Hide scroll bar because it appears sometimes unnecessarily, this does not prevent scrolling 
                parent.setVerticalScrollBarEnabled(false);
                return v;
            }
        };      
    adaptercreatetype.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    denominationselection.setAdapter(adaptercreatetype);



 customDialog.setPositiveButton("Save", new DialogInterface.OnClickListener(){

 @Override
 public void onClick(DialogInterface dialog,int which) {
 // TODO Auto-generated method stub

 }});

 customDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener(){

 @Override
 public void onClick(DialogInterface dialog,int which) {
 // TODO Auto-generated method stub

 }});

   customDialog.setView(view);
   customDialog.show();     

  }
  • 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-10T05:52:12+00:00Added an answer on June 10, 2026 at 5:52 am

    Very simple solution instead of…

    LayoutInflater layoutInflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    

    use…

    LayoutInflater layoutInflater = getLayoutInflater();
    

    This will alleviate your issue.

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

Sidebar

Related Questions

I'm looking for a tutorial that explains creating custom usercontrols in WPF. I want
i'm currently creating a custom dialog (alertdialog is not flexible enough for my needs).
I'm working on creating a custom dialog to get input from the user. I've
I am creating custom Swing components and want to provide a UI that looks
I need to implement creating custom gesture(like Gesture Builder in Android ) in my
I'm creating custom control that contain multiple parts. Inside template creation I'm subscribing for
I have a custom subclass of AlertDialog that should display a list of all
I am creating custom images that I later convert to an image pyramid for
Creating custom IHttpModules, I have realized that the requests for static files (e.g.: .css
I'm looking for tutorials on creating custom view transitions. In particular, transitions that involve

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.