for (int i = 0; i < radioGroup.getChildCount(); i++) { final RadioButton menu = (RadioButton) radioGroup.getChildAt(i); menu.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: curPress = menu.getId(); for (int j = 0; j < radioGroup.getChildCount(); j++) { if (curPress != radioGroup.getChildAt(j).getId()) { radioGroup.getChildAt(j).setEnabled(false); } } break; case MotionEvent.ACTION_UP: for (int j = 0; j < radioGroup.getChildCount(); j++) { if (curPress != radioGroup.getChildAt(j).getId()) { radioGroup.getChildAt(j).setEnabled(true); } } curPress = -1; break; } return false; } }); }
Android RadioGroup中的RadioButton同时点击显示异常问题
最新推荐文章于 2022-09-30 16:19:55 发布