gpt4 book ai didi

Android 5 - 导航栏上的微调器下拉列表

转载 作者:太空狗 更新时间:2023-10-29 14:57:12 24 4
gpt4 key购买 nike

我对 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) 确保您的 z 值 android:elevation= 正确。

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

关于Android 5 - 导航栏上的微调器下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30244897/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com