我正在做一个应用程序,其中我有产品详细信息屏幕,在该屏幕中我创建基于可配置项目的长度的动态微调。每件事情工作好,但是当我尝试根据第一个动态微调项目的选择更改其他动态微调项目的列表时,过滤的数组会被转移到点击微调列表,但它应该被添加到另一个微调项目,而不是我点击。请帮助我这我真的被困在这种情况下,我尝试了很多,但无法执行,所以我正在寻求你的帮助。基于任何微调项目选择在特定位置设置新数据在特定位置
情景是假设特定产品我有2个旋转器之一是用于色彩属性和其他为尺寸属性而且两者被相互对于实施例相通: -
在颜色微调我有三个颜色: - 白色,蓝色,绿色 同样在尺寸我有: - S,M,L,XL
但对于白色我有只有两种尺寸,即S和M 所以,我需要的是当用户点击Spinne时r具有颜色属性白色,第二个微调器中的数组自动变为S,M和viseversa
我正在做所有这些动态微调。
这里是我的代码: -
private void showconfigurableProducts() {
try {
count = 0;
mllSpinner.setVisibility(View.VISIBLE);
for (int i = 0; i < lisProductDetail.get(0).getConfigurable()
.size(); i++) {
TextView tv = new TextView(getActivity());
tv.setText(lisProductDetail.get(0).getConfigurable().get(i)
.getLabel());
mllSpinner.addView(tv);
final Spinner spinner = new Spinner(getActivity());
spinner.setTag(i);
final ArrayAdapter<OptionProductDetailModel> arrayAdapter=new ArrayAdapter<OptionProductDetailModel>(
getActivity(),
android.R.layout.simple_spinner_dropdown_item,
lisProductDetail.get(0).getConfigurable().get(i)
.getOptions());
spinner.setAdapter(arrayAdapter);
spinner.setSelection(0, false);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
private String attributeId;
@Override
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id) {
OptionProductDetailModel option = (OptionProductDetailModel) spinner
.getSelectedItem();
List<OptionProductDetailModel> sizedataArray = new ArrayList<OptionProductDetailModel>();
sizedataArray.add(option);
if (listDummy.size() > 0) {
selectbtatrue = check(sizedataArray, listDummy);
}
if (selectbtatrue) {
return;
} else {
for (int i = 0; i < lisProductDetail.get(0)
.getConfigurable().size(); i++) {
for (int j = 0; j < lisProductDetail.get(0)
.getConfigurable().get(i).getOptions()
.size(); j++) {
if (lisProductDetail.get(0)
.getConfigurable().get(i)
.getOptions().get(j).getLabel() == option
.getLabel()) {
attributeId = lisProductDetail.get(0)
.getConfigurable().get(i)
.getId();
}
}
}
for (int i = 0; i < lisProductDetail.get(0)
.getConfigurable().size(); i++) {
if (attributeId != lisProductDetail.get(0)
.getConfigurable().get(i).getId()) {
// if (listDummy.size() > 0) {
// listDummy = new
// ArrayList<OptionProductDetailModel>();
// }
for (int k = 0; k < option.getProducts()
.size(); k++) {
for (int j = 0; j < lisProductDetail
.get(0).getConfigurable()
.get(i).getOptions().size(); j++) {
for (int l = 0; l < lisProductDetail
.get(0).getConfigurable()
.get(i).getOptions().get(j)
.getProducts().size(); l++) {
if (option
.getProducts()
.get(k)
.equals(lisProductDetail
.get(0)
.getConfigurable()
.get(i)
.getOptions()
.get(j)
.getProducts()
.get(l))) {
listDummy
.add(lisProductDetail
.get(0)
.getConfigurable()
.get(i)
.getOptions()
.get(j));
} else {
}
}
}
System.out.print(listDummy);
}
}
if (count < 2) {
int tag = (int) spinner.getTag();
if (tag == i) {
} else {
lisProductDetail.get(0)
.getConfigurable().get(i)
.setOptions(listDummy); // Here i am getting S,M,L but i do not know how to update in in Size Attribute Spinner.
}
count = count + 1;
}
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
mllSpinner.addView(spinner);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private boolean check(List<OptionProductDetailModel> SelectedArray,
List<OptionProductDetailModel> DummyArray) {
for (int i = 0; i < SelectedArray.size(); i++) {
for (int j = 0; j < DummyArray.size(); j++) {
if (SelectedArray.get(i).getId()
.equalsIgnoreCase(DummyArray.get(j).getId())) {
btatrue = true;
} else {
btatrue = false;
}
}
}
return btatrue;
}
请提供您的建议,您的帮助将不胜感激 我都被浪费在这个问题上我的2天,是否可行或不动的情况下,微调。 谢谢
太复杂的解释方式和太复杂的代码。请简化你想要的东西! :) –
嘿吉米特,我只是想改变基于选择的任何微调项目的微调列表项目,条件是所有微调动态 – sid
然后尝试启动的方法。在第一个'onItemSelected'方法的'onItemSelected'方法内部填充另一个微调控制器,并在其'onItemSelected'方法内部填充下一个微调控制器,等等...... !!! –