如果我从月份微调器选择月份2月份,如果我选择白天作为30,则不应该这样做.
另一个例子:4月份有30天,所以如果有人选择Month作为April,将day作为31st,那么这是不正确的.请告诉我如何获取一个微调器的值对应于另一个微调器的值.
这是我的代码,我有两个微调器:
@OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); /*************day spinner**********/ Spinner day = (Spinner) findVIEwByID(R.ID.spinner2); ArrayAdapter<CharSequence> dayadapter = ArrayAdapter.createFromresource( this,R.array.item_day,androID.R.layout.simple_spinner_item); dayadapter.setDropDownVIEwResource(R.layout.spinner_layout); day.setAdapter(dayadapter); /*****************month spinner**********************/ Spinner month = (Spinner) findVIEwByID(R.ID.spinner3); ArrayAdapter<CharSequence> monthadapter = ArrayAdapter.createFromresource( this,R.array.item_month,androID.R.layout.simple_spinner_item); monthadapter.setDropDownVIEwResource(R.layout.spinner_layout); month.setAdapter(monthadapter);}}
我的Xml定义了微调器:
<Spinner androID:ID="@+ID/spinner2" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignleft="@+ID/spinner3" androID:layout_aligntop="@+ID/textVIEw4" androID:layout_toleftOf="@+ID/textVIEw3" /> <Spinner androID:ID="@+ID/spinner3" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_below="@+ID/spinner2" androID:layout_toleftOf="@+ID/textVIEw3" androID:layout_toRightOf="@+ID/textVIEw5" />
我的spinner_layout:
<?xml version="1.0" enCoding="utf-8"?><TextVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:ID="@+ID/spinnerTarget" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:textcolor="#000000" androID:textSize="12pt"/>
我的日子
<string name="day_picker">Select an iten</string><string-array name="item_day"> <item>1</item> <item>2</item> <item>3</item> <item>4</item> <item>5</item> <item>6</item> <item>7</item> <item>8</item> <item>9</item> <item>10</item> <item>11</item> <item>12</item> <item>13</item> <item>14</item> <item>15</item> <item>16</item> <item>17</item> <item>18</item> <item>19</item> <item>20</item> <item>21</item> <item>22</item> <item>23</item> <item>24</item> <item>25</item> <item>26</item> <item>27</item> <item>28</item> <item>29</item> <item>30</item> <item>31</item></string-array>
我的月阵
<resources> <string name="month_picker">Select an item</string> <string-array name="item_month"> <item>January</item> <item>February</item> <item>march</item> <item>April</item> <item>May</item> <item>June</item> <item>July</item> <item>August</item> <item>September</item> <item>October</item> <item>November</item> <item>December</item> </string-array></resources>
如果我选择任何一个月我想得到相应的没有.白天自动旋转的日子
注意:单击按钮后我不希望出现任何错误消息.提前致谢.
month.setonItemSelectedListener(new OnItemSelectedListener() { @OverrIDe public voID onItemSelected(AdapterVIEw<?> parent,VIEw vIEw,int pos,long ID) { // Todo auto-generated method stub List<String> s = Arrays.asList(getResources().getStringArray(R.array.item_day)); if (pos == 0 || pos == 2 || pos == 4 || pos == 8 || pos == 9 || pos == 11) { ArrayAdapter<String> dayadapter = new ArrayAdapter<String>(Latlondemo.this,androID.R.layout.simple_spinner_item,s); day.setAdapter(dayadapter); } else if (pos == 1) { s = s.subList(0,28); ArrayAdapter<String> dayadapter = new ArrayAdapter<String>(Latlondemo.this,s); day.setAdapter(dayadapter); } else { s = s.subList(0,30); ArrayAdapter<String> dayadapter = new ArrayAdapter<String>(Latlondemo.this,s); day.setAdapter(dayadapter); } } @OverrIDe public voID onnothingSelected(AdapterVIEw<?> arg0) { // Todo auto-generated method stub } });总结
以上是内存溢出为你收集整理的android – 如何获取微调器值取决于其他微调器全部内容,希望文章能够帮你解决android – 如何获取微调器值取决于其他微调器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)