我在Android编程中遇到了问题 :/ 我已经通过编程方式创建了布局,但是下拉列表的下拉框并不按预期工作...正如你所看到的这里,它们覆盖了底部的导航栏。
仅在Android 5(API级别21)及以上版本中出现此情况。我已经在Android 4.XX上测试过了,它运行良好。
这可能是一个Android的bug吗?
谢谢 :)
PS:这是我的部分代码:
仅在Android 5(API级别21)及以上版本中出现此情况。我已经在Android 4.XX上测试过了,它运行良好。
这可能是一个Android的bug吗?
谢谢 :)
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));