问题描述
问题了
对此微调的布局和想要得到的依赖2微调
结构
Have 2 spinner on layout and wanna get dependence of this spinnerStructure
String[] main={"Moscov","LosAngeles","Pekin"};
String[] one={"1","2","3","4"};
String[] two={"2","2","5","8"};
String[] tree={"5","7","3","2"};
创建用于主阵列第一微调第一适配器。
而对于依赖项目选择必须依赖与阵列混凝土适配器的选择
如果项目1然后用数组一个适配器,如果第2项则阵列中有两个
Create first adapter for first spinner with main array.And dependently for item choice must crete adapter with array which depend of choice If item 1 then adapter with array one, if item 2 then array two
推荐答案
您将创建微调
键,只需设置适配器
第二微调
根据使用 onItemSelected
上的第一个微调。类似
You will create your spinner
and just set the Adapter
for the second spinner
according to the selection using onItemSelected
on the first Spinner
. Something like
@Override
public void onItemSelected(AdapterView<?> spinner, View view, int position,long arg3)
{
TextView tv = (TextView)view; // convert the view to TextView
String selected = tv.getText().toString();
if (selected.equals("Moscov"))
{
// set the Adapter here with the first set of values
}
else if(selected.equals("LosAngeles"))
{
// set the Adapter here with the second set of values
}
else
{
// set the Adapter here with the third set of values
}
}
您也可以使用位置
如果你把你的字符串数组
到<$这可能是更具可扩展性C $ C>的ArrayList 。
You also could use the position
which may be more scalable if you put your String Arrays
into an ArrayList
.
这篇关于依赖android系统中的数据微调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!