我有一个Spinners问题ListView。我有一个ListView带有CheckBox一个标签和两个的Spinners。这些Spinner是从 SQLite 填充的,并且工作正常。我没有使用该ViewHolder方法,因为到目前为止,当ListView单击该行时,CheckBoxes已选中或未选中,并且更改会立即保存到数据库中。选中该行时,该行变为Spinners可见,但未选中该行时不可见。
所以我没有设法找到解决方案的问题是我不知道如何获得实际Spinner的,甚至不知道如何获得ListItem点击Spinner所在的行。Activity延伸ListActivity。_ 任何人都知道我可以在不使用 a 的情况下做到这一点,ViewHolder还是必须使用 a ViewHolder?
这是声明和填充的代码ListView:
mSsCursor = mDbHelper.fetchAllSsPlaylistSs(mPlId);
        startManagingCursor(mSsCursor);
        String[] from = new String[]{"pl_selected", BTDbAdapter.KEY_NAME, BTDbAdapter.KEY_NAME2};
        int[] to = new int[]{R.id.pl_selected, R.id.name, R.id.name2};
        mAllSs = new SimpleCursorAdapter(this, R.layout.pl_edit_ss_row, mSsCursor, from, to);
        mAllSs.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
        //custom handling of setting the value
        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            if(columnIndex == 3) {
                    ViewGroup row = (ViewGroup)view.getParent().getParent();
                    mSId = cursor.getInt(0);
                    if (cursor.getInt(3) > 0) {
                        mCheckBox = (CheckBox) row.findViewById(R.id.pl_selected);
                        mCheckBox.setChecked(true);
                        mTSpin = (Spinner) row.findViewById(R.id.pl_t_spin);
                        mMSpin = (Spinner) row.findViewById(R.id.pl_m_spin);
                        mtvT = (TextView) row.findViewById(R.id.pl_t);
                        mtvM = (TextView) row.findViewById(R.id.pl_m);
                        mTSpin.setVisibility(View.VISIBLE);
                        mtvT.setVisibility(View.VISIBLE);
                        mMSpin.setVisibility(View.VISIBLE);
                        mtvM.setVisibility(View.VISIBLE);
                        //set the values in the t spinner
                        PopulateTSpinner(cursor.getInt(4));
                        //set the values in the m spinner
                        PopulateMSpinner(cursor.getInt(5));
                    }
                    else {
                        mCheckBox = (CheckBox) row.findViewById(R.id.pl_selected);
                        mCheckBox.setChecked(false);
                        mTSpin = (Spinner) row.findViewById(R.id.pl_t_spin);
                        mMSpin = (Spinner) row.findViewById(R.id.pl_m_spin);
                        mtvT = (TextView) row.findViewById(R.id.pl_t);
                        mtvM = (TextView) row.findViewById(R.id.pl_m);
                        mTSpin.setVisibility(View.GONE);
                        mtvT.setVisibility(View.GONE);
                        mMSpin.setVisibility(View.GONE);
                        mtvM.setVisibility(View.GONE);
                    }                   
                    return true;
            }
            return false;
        }
    });
    setListAdapter(mAllSs);
谢谢。