我的 xml 中有 3 个微调器。
1. one is Product Name
2. one is Product Quantity.
3. and 3rd one is Discount
现在,我为每个调用单独的侦听器..问题是我想使用项目数量来计算最终价格,我以相同的顺序调用了微调器,即我写了名称、数量和折扣..
即使我在 Discount Spinner 上面写了,最后还是调用了 Quantity 的侦听器..我不知道发生了什么..任何人都可以面对这个问题...请帮助我..
这是我的 Spinner 监听器:-
spnSelectItem.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3)
{
strItem=spnSelectItem.getItemAtPosition(arg2).toString(); }
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
///This method called last..
spnQty.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3)
{
strQty=spnQty.getItemAtPosition(arg2).toString();
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
///This method called before spnQty ..
spnItemDiscount.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3)
{
disc=round(Double.parseDouble(spnItemDiscount.getItemAtPosition(arg2).toString().replace("%", "")));
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});