【发布时间】:2015-05-18 00:02:35
【问题描述】:
我对 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));
【问题讨论】:
标签: android spinner android-5.0-lollipop