Android 5 - 导航栏上的Spinner下拉列表

时间:2015-05-14 18:41:50

标签: android spinner android-5.0-lollipop

我的Android编程存在问题:/
我已经以编程方式创建了一个布局,但是微调器的下拉列表无法正常工作......正如您所见here,它们覆盖了底部的导航栏。

仅适用于Android 5(API级别21)及以上版本。 我已经在Android 4.XX上测试了它,效果很好。

这可能是Android的错误吗?

谢谢:)

PS:这是我的代码的一部分:

   //--- SPINNER ---
        spinnersArray[j] = new Spinner(getActivity().getApplicationContext());
        spinnersArray[j].setId(j+100); //set a different ID

        //Create the Array that will populate the Spinner, than shuffle it
        Character[] tmpArray = new Character[1 + plaintextCharsArray.length]; 
        tmpArray[0] = ciphertextCharsArray[j]; //first char is a symbol
        Character[] shuffledPlainTextCharsArray = MyUtils.shuffleArray(plaintextCharsArray.clone()); //shuffle a copy of plaintextCharsArray
        for (int i=0; i<plaintextCharsArray.length; i++){
            tmpArray[i+1] = shuffledPlainTextCharsArray[i];
        }

        //Spinner ArrayAdapter 
        final ArrayAdapter<Character> spinnerArrayAdapter = new ArrayAdapter<Character>(
                parentActivity.getApplicationContext(), 
                R.layout.game_controller_fragment_spinner, 
                tmpArray){

                public View getView(int position, View convertView, ViewGroup parent) {
                    View v = super.getView(position, convertView, parent);
                    ((TextView) v).setTypeface(font);   //Set the FONT

                    return v;
                }

                public View getDropDownView(int position, View convertView, ViewGroup parent) {
                    View v = super.getDropDownView(position, convertView, parent);
                    ((TextView) v).setTypeface(font);   //Set the FONT
                    return v;
                }
        };

        //Set the style and the adapter
        spinnerArrayAdapter.setDropDownViewResource(R.layout.game_controller_fragment_spinner_dropdown);
        spinnersArray[j].setBackgroundResource(R.drawable.apptheme_spinner_background_holo_light);
        spinnersArray[j].setAdapter(spinnerArrayAdapter);

        //Find and set the current Spinner selected item
        int h = 0; boolean found = false;
        while ((!found) && (h<tmpArray.length)){
            if (gameArray[j] == tmpArray[h]){
                spinnersArray[j].setSelection(h); //set the Spinner selected item
                found = true;
            }
            h++;
        }

        //Spinner item listener
        spinnersArray[j].setOnItemSelectedListener(new MyItemSelectedListener(tmpArray, j)); 

1 个答案:

答案 0 :(得分:0)

主要问题可能有两个,虽然我没有以编程方式完成此操作。我已经碰到了很多次。

1)确保您的z值android:elevation=正确无误。

2)很多时候它是定义它的顺序,无论是在实际的xml布局中还是以等效的方式,以及它所包含的布局类型。我的经验是我后来定义的项目当涉及到z或高程时,请优先考虑。