Android Spinner Error : android.view.WindowManager$BadTokenException: Unable to add window

前端 未结 6 1418
滥情空心
滥情空心 2020-11-29 10:43

I want to set the spinner value using String[] or ArrayList.

I have done spinner in other activity working fine.In this activity inside the Tab acivityGroup another

6条回答
  •  眼角桃花
    2020-11-29 11:17

    I had this problem as well, but with Fragments, when adding a fragment to a view, and the answer for me was to pass in getApplicationContext(), but I had to do it through a separate method after instantiating the fragment, since it was requiring the use of a Bundle.

    I also had to do the following when inflating the view, using the context passed in above:

    View v = inflater.from(context).inflate(R.layout.layout_name, ViewGroup container, T/F);
    

    rather than just:

    View v = inflater.from(context).inflate(R.layout.layout_name, ViewGroup container, T/F);
    

    Hope this helps somebody struggling with Fragments.

提交回复
热议问题