android-我的微调器未调用OnItemSelectedListener()

嗨,我有一个微调器,我已经使用可见性=隐藏属性.我使用spinner.performclick()调用微调器列表,除了在微调器列表中选择一个项目时,永远不会调用我的onselect侦听器外,此方法工作正常.请帮忙:)

唯一引发的警告警告是“窗口已经聚焦,而忽略了聚焦增益”

        catagorySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
            CashDB cdb = new CashDB(getBaseContext()); 
            cdb.open();
            Cursor c = cdb.FetchCatagory(id);
            startManagingCursor(c);
            c.moveToFirst();
            String newCatagoryName = c.getString(c.getColumnIndexOrThrow(CashDB.CATAGORY_NAME));
            c.close();
            areYouSureDialog("Are You Sure?", "Are you sure you want to delete the catagory " +'"' 
                    + catagoryName + '"'+ " and move all of the transactions to " +'"' 
                    + newCatagoryName + '"' + " ?",
                    catagoryIcon, catagoryName,newCatagoryName, DELETE_CATAGORY_MOVE, catagoryId);
        }

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

解决方法:

将微调框的可见性保留为INVISIBLE,但将android:layout_width =“ 0dp”和android:layout_height =“ 0dp”设置为

这样,微调器实际上不会出现在UI中,直到您调用performClick(),然后它出现,用户做出选择,微调器折叠回0x0 …并得到onItemSelected事件.

上一篇:墨问非名-汉化教程5——自动分页填字


下一篇:使用Javascript的所选单词的索引