相关疑难解决方法(0)

Spinner:当选定项保持不变时,不会调用onItemSelected

我有一个OnItemSelectedListenerfor my Spinner,但是当所选项目与前一个项目相同时,它不会被调用.显然,OnClickListener这不是一个选项Spinner.每次用户点击某个项目时我都需要抓住.任何的想法?

也许这SpinnerActionBar扰乱正常行为的事实?

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.tracklist_menu, menu);
    Spinner spinner = (Spinner) menu.findItem(R.id.option_ordering_spinner)
            .getActionView();
    spinner.setAdapter(mSpinnerAdapter);
    spinner.setSelection(PrefsHelper.getOrderingSpinnerPos(prefs));
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view,
                int position, long id) {
            String str = "selected";
            System.out.println(str);
            if (optionMenuInitialized) {

                switch (position) {
                case 0:
                    // rdm
                    getActivity()
                            .sendBroadcast(
                                    new Intent(
                                            MyIntentAction.DO_RESHUFFLE_PLAYLIST));
                    smp.setCurrentTracklistCursorPos(-1);
                    trackAdapter.notifyDataSetChanged();
                    break;
                case 1:
                    // artist
                    getActivity()
                            .sendBroadcast(
                                    new Intent(
                                            MyIntentAction.DO_ORDER_PLAYLIST_BY_ARTIST)); …
Run Code Online (Sandbox Code Playgroud)

android listener spinner actionbarsherlock android-actionbar

45
推荐指数
6
解决办法
3万
查看次数