Android :WindowManager$BadTockenException on Spinner Click

后端 未结 1 2053
[愿得一人]
[愿得一人] 2020-12-12 00:06

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 callin

相关标签:
1条回答
  • 2020-12-12 00:47

    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 讨论(0)
提交回复
热议问题