为什么spinner继续调用setOnItemSelectedListener

时间:2012-01-12 01:34:15

标签: android spinner

我的代码很简单。但是当我输入这个活动时,活动将继续调用spinner.setOnItemSelectedListener()。onItemSelected()

ArrayAdapter<CharSequence> adapterCatalog = new ArrayAdapter<CharSequence>(mContext, R.layout.simple_spinner_item_rank,catalogs);
adapterCatalog.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerCatalog.setPromptId(R.string.search_select_category);
spinnerCatalog.setAdapter(adapterCatalog);
spinnerCatalog.setSelection(0, false);
spinnerCp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
    {
        MySharedPreferences.setSearchCatagoryFilter(catalogIDs.get(position));
        MySharedPreferences.save();
        mCurrPageIndex = 1;
        Log.e(tag,"fillSpinnerCatalog() calls  sendRequest()");
        sendRequest();
    }

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

我不知道为什么onItemSelected()总是每隔10秒调用一次以及如何重新解决这个问题。

0 个答案:

没有答案