@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.menulist: // 左边选项菜单的点击 if (!tabMenu(position)) { // 替换片段不成功直接return return; } break; case R.id.room_menu_listview: setMenuItemClick(position); break; case R.id.menu_listview: closeRoomPopUpWindow(); tabMenu(0); SPdata.writeSelectBoardRoomPosition(this, position); initParameter(position); mMenuListViewAdapter.clearEquipList(); mMenuListViewAdapter.setEquipList(mEquipList); mMenuListViewAdapter.notifyDataSetChanged(); break; default: break; } }
/** * 选项菜单点击,片段的切换,要是之前已经选中,直接返回false * * @param position * @return */ private boolean tabMenu(int position) { if (mNowPosition == position) { return false; } else { mNowPosition = position; } Fragment fragment = null; mMenuListViewAdapter.setPosition(position); mMenuListViewAdapter.notifyDataSetChanged(); if (mEquipList == null || mEquipList.size() == 0) { return false; } switch (mEquipList.get(position)) { case 0: // 情景控制 fragment = new TabSituation(); mTextModeSheet.setText(R.string.situation_sheet); break; case 1: // 窗帘控制 fragment = new TabCurtain(); mTextModeSheet.setText(R.string.curtain_sheet); break; case 2: // 投影控制 fragment = new TabProjector(); mTextModeSheet.setText(R.string.projector_sheet); break; case 3: // 空调控制 fragment = new TabAirCondition(); mTextModeSheet.setText(R.string.air_sheet); break; case 4: // 电视控制 fragment = new TabMusic(); mTextModeSheet.setText(R.string.music_sheet); break; case 5: // 音响输出 fragment = new TabTV(); mTextModeSheet.setText(R.string.tv_sheet); break; case 6: // 音乐控制 fragment = new TabScreen(); mTextModeSheet.setText(R.string.tong_sheet); break; case 7: // 同屏输出 fragment = new TabSound(); mTextModeSheet.setText(R.string.sound_sheet); break; default: break; } replaceFragment(fragment); return true; }