1

我正在制作带有多个片段的微调器控件,第一个片段正确显示微调器,然后第二个片段调用然后我设置默认微调器未设置请帮助我,提前谢谢

String[] strArraySpinner = { "Existing Customer ?", "New Customer ?" };
    mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (mSpinner.getSelectedItem().toString().equalsIgnoreCase(strArraySpinner[0])) {
                Toast toast = Toast.makeText(mContext, "Item= " + mSpinner.getSelectedItem().toString(), Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER, 0, 0);
                toast.show();
            } else if (mSpinner.getSelectedItem().toString().equalsIgnoreCase(strArraySpinner[1])) {
                Toast toast = Toast.makeText(mContext, "Item= " + mSpinner.getSelectedItem().toString(), Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER, 0, 0);
                toast.show();
            }  
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });

当我在微调器调用上选择方法时调用第二个片段,这不起作用,

mSpinner.setSelection();  // here i m set on default spinner with prompt
4

1 回答 1

0

我为自己的解决方案找到了mSpinner.setSelection();方法删除并再次设置适配器调用的微调器,

mSpinner.setAdapter(new SpinnerBaseAdapter(mContext, strArraySpinner);

这工作正常,并为下拉列表中的每个项目进行更改并获得结果。

于 2013-08-03T05:19:36.800 回答