def countVowels(str1):
str1_array = str1.split(" ")
vA = ["A", "a"]
vE = ["E", "e"]
vI = ["I", "i"]
vO = ["O", "o"]
vU = ["U", "u"]
vA_count = 0
for vA in str1_array:
vA_count = vA_count + 1
vE_count = 0
for vE in str1_array:
vE_count = vE_count + 1
vI_count = 0
for vI in str1_array:
vI_count = vI_count + 1
vO_count = 0
for vO in str1_array:
vO_count = vO_count + 1
vU_count = 0
for vU in str1_array:
vU_count = vU_count + 1
print("A, E, I, O, and U appear, respectively, ", vA_count, vE_count, vI_count, vO_count, "and", vU_count, "times.")
onItemSelected的情况0内的条件“ if(height_spinner.getSelectedItemPosition()== 1)”未得到执行,仅条件“ if(height_spinner.getSelectedItemPosition()== 0)”已执行。
onItemSelected案例0内的条件“ if(height_spinner.getSelectedItemPosition()== 1)”未得到执行,仅条件“ if(height_spinner.getSelectedItemPosition()== 0)”已被执行。
请提出修改建议并解决我的问题
答案 0 :(得分:1)
这是因为当您处于位置0(又称为情况0)时:
@Override
public void onItemSelected(AdapterView parent, View view, int position, long id) {
switch (position){
case 0:
weight_et.setHint("Weight(kg)");
weight_et1.setVisibility(View.GONE);
weight_et1.setEnabled(false);
weight_et.setEnabled(true);
if (height_spinner.getSelectedItemPosition()==0) {...}
代码:height_spinner.getSelectedItemPosition()
等于0(在位置1,它将等于1,依此类推)
因此条件:height_spinner.getSelectedItemPosition() == 1
不会在情况0时被调用