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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:03:41+00:00 2026-05-19T02:03:41+00:00

I have a spinner in my home.class. When I click on the spinner, the

  • 0

I have a spinner in my home.class. When I click on the spinner, the process is stopped showing exception that WindowManager$BadTockenException is caught.

I am calling this home.class from main.class which extends ActivityGroup.

If I am simply run only the home.class, the spinner is showing all items. But the problem is only with calling home.class from main.class.

The following are my code. Please tell me why this is happened.

main.class

public class main extends ActivityGroup
{
  public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
       Intent intent=new Intent(this,home.class);
       View view=getLocalActivityManager().startActivity("1", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
       setContentView(view);
  }

}

home.class

String[] country={"Please selects","US","INDIA","UK"};
Spinner s2 = (Spinner) findViewById(R.id.spinnerCountry);
ArrayAdapter<CharSequence> adapterCountry=new ArrayAdapter(this,android.R.layout.simple_spinner_item,country);
adapterCountry.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s2.setAdapter(adapterCountry);

s2.setOnItemSelectedListener(new OnItemSelectedListener()
{
     public void onItemSelected( AdapterView<?> parent, View view, int position, long id)
     {
            countryName=country[position];
     }

      public void onNothingSelected(AdapterView<?> parent)
     {
            countryName=country[0];
      }

});

Stack

Thread [<1> main] (Suspended (exception WindowManager$BadTokenException))
AlertDialog(Dialog).show() line: 245
AlertDialog$Builder.show() line: 802
Spinner.performClick() line: 260
View$PerformClick.run() line: 9080
ViewRoot(Handler).handleCallback(Message) line: 587
ViewRoot(Handler).dispatchMessage(Message) line: 92
Looper.loop() line: 123
ActivityThread.main(String[]) line: 3647
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object…) line: 507
ZygoteInit$MethodAndArgsCaller.run() line: 839
ZygoteInit.main(String[]) line: 597
NativeStart.main(String[]) line: not available [native method]

Thank You….

  • 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-05-19T02:03:42+00:00Added an answer on May 19, 2026 at 2:03 am

    The error may be with the setContentView given inside your home.class.

    Instead of setContentView(yourlayout);

    give,

    View viewToLoad = LayoutInflater.from(this.getParent()).inflate(yourlayout, null);
    this.setContentView(viewToLoad);  
    Spinner s2 = (Spinner) viewToLoad.findViewById(R.id.spinnerCountry);
    

    And give your spinner code as:

    ArrayAdapter<CharSequence> adapterCountry=new ArrayAdapter(this.getParent(),android.R.layout.simple_spinner_item,country);
    adapterCountry.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    s2.setAdapter(adapterCountry);
    

    Since you are using activity group, you face this issue. Hope this solution may help you.

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

Sidebar

Related Questions

I have a settings class. In this class I have a spinner, with 4
I have a spinner, and I do this public class Settings extends Activity {
I have one spinner, and I am populating that. I have list of values
I have a Spinner and a SimpleCursorAdapter . For odd/even rows on this spinner
Hi I have a spinner (spinner5) and whenever the user selects an item that
my 1st page have a spinner, that will parse value to the 2nd activity..
The functionality I want is this: I have a set of URLs that I
I have a Spinner with an ArrayAdapter that feeds Values into it. The layout
Imagine I have a spinner that I have to enable while something relatively heavy
I have a Spinner and I want to fill this one with a currency

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.