微调器选择的活动变化

时间:2015-07-15 02:33:14

标签: android

我有以下方法。出于某种原因,我的活动并没有改变微调器选择的变化。假设在我的switch语句中,微调器中的第一个值等于值“1”。

public void addListener() {
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onItemSelected(AdapterView<?> arg0, View view,
                                   int position, long row_id) {
            Intent intent = getIntent();
            switch (position) {
                case 1:
                    intent = new Intent(ListCarsActivity.this, ListCarsActivity.class);

                    break;
                case 2:
                    intent = new Intent(ListCarsActivity.this, ListOwnersActivity.class);
                    break;


            }
            startActivity(intent);

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }

    });
}

0 个答案:

没有答案