/** 初始化单选按钮组 */ public void initRadioGroup() { baoRadioGroup = (RadioGroup) findViewById(R.id.buy_join_radiogroup_baodi); for (int i = 0; i < baoTitle.length; i++) { RadioButton radio = new RadioButton(this); radio.setText(baoTitle[i]); radio.setTextColor(Color.BLACK); radio.setTextSize(13); radio.setId(i); radio.setButtonDrawable(R.drawable.radio_select); radio.setPadding(Constants.PADDING, 0, 10, 0); baoRadioGroup.addView(radio); } baoRadioGroup.setOnCheckedChangeListener(this); baoRadioGroup.check(1); openRadioGroup = (RadioGroup) findViewById(R.id.buy_join_radiogroup_open); for (int i = 0; i < openTitle.length; i++) { RadioButton radio = new RadioButton(this); radio.setText(openTitle[i]); radio.setTextColor(Color.BLACK); radio.setTextSize(13); radio.setId(i); radio.setButtonDrawable(R.drawable.radio_select); radio.setPadding(Constants.PADDING, 0, 10, 0); openRadioGroup.addView(radio); } openRadioGroup.setOnCheckedChangeListener(this); openRadioGroup.check(0); }
/** 检测Radiobutton当前选中状态,做出字体颜色改变 */ public void changeRadioButoonColor() { for (int i = 0; i < typeGroup.getChildCount(); i++) { RadioButton radioButton = (RadioButton) typeGroup.getChildAt(i); if (radioButton.isChecked()) { radioButton.setTextColor(Color.BLACK); } else { radioButton.setTextColor(Color.WHITE); } } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public ComponentAdapter<RadioGroup> createComponent(ConfigRadio configRadio) { int[][] states = new int[][] { new int[] {android.R.attr.state_enabled}, // enabled new int[] {-android.R.attr.state_enabled}, // disabled new int[] {-android.R.attr.state_checked}, // unchecked new int[] {android.R.attr.state_pressed} // pressed }; int[] colors = new int[] {Color.BLACK, Color.RED, Color.GREEN, Color.BLUE}; ColorStateList myList = new ColorStateList(states, colors); RadioGroup group = new RadioGroup(AndroidConfiguration.getInstance().getCurrentContext()); Map<String, RadioButton> buttons = new HashMap<String, RadioButton>(); for (Object value : configRadio.getValues()) { RadioButton radio = new RadioButton(AndroidConfiguration.getInstance().getCurrentContext()); radio.setText(value.toString()); radio.setTextColor(Color.BLACK); buttons.put(value.toString(), radio); radio.setButtonTintList(myList); group.addView(radio); } return new AndroidRadioAdapter(group, buttons); }
@Override public void reset() { RadioButton radio = (RadioButton) view.findViewById(view.getCheckedRadioButtonId()); if (radio != null) { radio.setTextColor(mColor); } }
@Override public void onError(ValidationFailure[] failures) { RadioButton radio = (RadioButton) view.findViewById(view.getCheckedRadioButtonId()); if (radio != null) { mColor = radio.getCurrentTextColor(); radio.setTextColor(view.getContext().getResources().getColor(R.color.error)); } }
/** 初始化选中状态 */ private void initRadioStates() { initRadioButtonStatus(); switch (scope) { case 1: rbtn_keyword_full.setTextColor(Color.WHITE); rbtn_keyword_full.setChecked(true); break; case 2: rbtn_keyword_position_name.setTextColor(Color.WHITE); rbtn_keyword_position_name.setChecked(true); break; case 3: rbtn_keyword_enterprise_name.setTextColor(Color.WHITE); rbtn_keyword_enterprise_name.setChecked(true); break; } }
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (rbUnlock.isChecked()) { rbUnlock.setTextColor(Color.WHITE); rbUnlock.setBackgroundResource(R.drawable.tab_left_pressed); rbLock.setTextColor(Color.GRAY); rbLock.setBackgroundResource(R.drawable.tab_right_default); FragmentTransaction ft = mFm.beginTransaction(); ft.replace(R.id.flContent, new FragmentUnlock()).commit(); } else if (rbLock.isChecked()) { rbUnlock.setTextColor(Color.GRAY); rbUnlock.setBackgroundResource(R.drawable.tab_left_default); rbLock.setTextColor(Color.WHITE); rbLock.setBackgroundResource(R.drawable.tab_right_pressed); FragmentTransaction ft = mFm.beginTransaction(); ft.replace(R.id.flContent, new FragmentLock()).commit(); } }
public void initTopButton() { for (int i = 0; i < topTitle.length; i++) { RadioButton radio = new RadioButton(this); radio.setText(topTitle[i]); radio.setTextColor(Color.BLACK); radio.setTextSize(13); radio.setId(i); radio.setButtonDrawable(R.drawable.radio_select); radio.setPadding(Constants.PADDING, 0, 10, 0); topButton.addView(radio); } }
public void populateRadioGroup() { if (radioGroup == null || populateRadioGroup == false) return; for (int i = 0; i < groupList.length; i++) { RadioButton radioButton = new RadioButton(context); radioButton.setText(groupList[i].name); radioButton.setId(groupList[i].grpid); radioButton.setTextColor(R.color.text_dark_green); radioGroup.addView(radioButton); } radioGroup.invalidate(); }
/** 初始化单选按钮组 */ public void initRadioGroup() { topButton = (RadioGroup) findViewById(R.id.buy_zixuan_radiogroup_top); for (int i = 0; i < topTitle.length; i++) { RadioButton radio = new RadioButton(this); radio.setText(topTitle[i]); radio.setTextColor(Color.BLACK); radio.setTextSize(13); radio.setId(i); radio.setButtonDrawable(R.drawable.radio_select); radio.setPadding(Constants.PADDING, 0, 6, 0); topButton.addView(radio); } topButton.setOnCheckedChangeListener(this); topButton.check(0); }
private void init() { homePageRadioButton = (RadioButton) findViewById(R.id.homePageRadioButton); homePageRadioButton.setOnClickListener(this); homeCommodityRadioButton = (RadioButton) findViewById(R.id.homeCommodityRadioButton); homeCommodityRadioButton.setOnClickListener(this); homeShoppingCartRadioButton = (RadioButton) findViewById(R.id.homeShoppingCartRadioButton); homeShoppingCartRadioButton.setOnClickListener(this); homePersonalRadioButton = (RadioButton) findViewById(R.id.homePersonalRadioButton); homePersonalRadioButton.setOnClickListener(this); homePageFragment = new HomepageFragment(); commodityFragment = new CommodityFragment(); shoppingCartFragment = new ShoppingCartFragment(); personalFragment = new PersonalFragment(); // 初始化第一个页面 changeFrament(homePageFragment, null, "homePageFragment"); homePageRadioButton.setCompoundDrawablesWithIntrinsicBounds( 0, R.drawable.home_homepage_tab_pressed2, 0, 0); homePageRadioButton.setTextColor(getResources().getColor(R.color.common_title_bg)); }
// 初始化信息 public void init() { mainRadioButton = (RadioButton) findViewById(R.id.mainRadioButton); mainRadioButton.setOnClickListener(this); robRadioButton = (RadioButton) findViewById(R.id.robRadioButton); robRadioButton.setOnClickListener(this); myinfoRadioButton = (RadioButton) findViewById(R.id.myinfoRadioButton); myinfoRadioButton.setOnClickListener(this); mainFragment = new MainFragment(); robFragment = new RobFragment(); myinfoFragment = new MyinfoFragment(); // 初始化第一个页面 changeFrament(mainFragment, null, "mainFragment"); mainRadioButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab_main_pressed, 0, 0); mainRadioButton.setTextColor(getResources().getColor(R.color.common_title_bg)); // 注册接收消息广播 receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // 设置广播的优先级别大于Mainacitivity,这样如果消息来的时候正好在chat页面,直接显示消息,而不是提示消息未读 intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // 注册一个ack回执消息的BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter(EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // 注册一个透传消息的BroadcastReceiver IntentFilter cmdMessageIntentFilter = new IntentFilter(EMChatManager.getInstance().getCmdMessageBroadcastAction()); cmdMessageIntentFilter.setPriority(5); registerReceiver(cmdMessageReceiver, cmdMessageIntentFilter); // 通知sdk,UI 已经初始化完毕,注册了相应的receiver和listener, 可以接受broadcast了 EMChat.getInstance().setAppInited(); }
private void initLayouts() { L.log("Initialize Layouts..."); rbTestTypeGroup = (RadioGroup) findViewById(R.id.rbTestTypeGroup); rbDownloadConfigurationTest = (RadioButton) findViewById(R.id.rbDownloadConfigurationTest); rbManualConfigurationTest = (RadioButton) findViewById(R.id.rbManualConfigurationTest); rbExternalTest = (RadioButton) findViewById(R.id.rbExternalTest); rbDownloadConfigurationTest.setChecked(false); rbManualConfigurationTest.setChecked(false); rbExternalTest.setChecked(false); String sLevel = pref.getUserLevel(); debug("Logged in user -> + " + pref.getUsername() + "; Level -> " + sLevel); if (sLevel.equalsIgnoreCase(StringUtils.USER_LEVEL_TECHNICIAN)) { rbManualConfigurationTest.setEnabled(false); rbManualConfigurationTest.setTextColor(color.gray_light); } ((TextView) findViewById(R.id.txt_settings)) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { Intent i = new Intent(TestTypeActivity.this, SettingsActivity.class); startActivityForResult(i, 1); } }); // rbTestTypeGroup.setSelected(false); rbTestTypeGroup.setOnCheckedChangeListener(chkListener); isAnyOfTestRunning = false; if (pref.isTestRunning()) isAnyOfTestRunning = true; btnStopTest = (Button) findViewById(R.id.btnStopTest); btnStopTest.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { stopTest(); } }); btnUploadFailedResults = (Button) findViewById(R.id.btnUploadFailedResults); btnUploadFailedResults.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { doUploadFailedResults(); } }); if (isAnyOfTestRunning) { boolean ext_tst_runng = pref.isExternalTestRunning(); if (ext_tst_runng) btnStopTest.setVisibility(View.GONE); else btnStopTest.setVisibility(View.VISIBLE); } else { btnStopTest.setVisibility(View.GONE); /*new Timer().schedule(new TimerTask() { @Override public void run() { activity.runOnUiThread(new Runnable() { @Override public void run() { btnStopTest.setVisibility(View.GONE); } }); } }, 5000);*/ } }
private void showQuestion(int qIndex, boolean review) { try { JSONObject aQues = QuizFunActivity.getQuesList().getJSONObject(qIndex); String quesValue = aQues.getString("Question"); if (correctAns[qIndex] == -1) { String correctAnsStr = aQues.getString("CorrectAnswer"); correctAns[qIndex] = Integer.parseInt(correctAnsStr); } question.setText(quesValue.toCharArray(), 0, quesValue.length()); answers.check(-1); answer1.setTextColor(Color.WHITE); answer2.setTextColor(Color.WHITE); answer3.setTextColor(Color.WHITE); answer4.setTextColor(Color.WHITE); JSONArray ansList = aQues.getJSONArray("Answers"); String aAns = ansList.getJSONObject(0).getString("Answer"); answer1.setText(aAns.toCharArray(), 0, aAns.length()); aAns = ansList.getJSONObject(1).getString("Answer"); answer2.setText(aAns.toCharArray(), 0, aAns.length()); aAns = ansList.getJSONObject(2).getString("Answer"); answer3.setText(aAns.toCharArray(), 0, aAns.length()); aAns = ansList.getJSONObject(3).getString("Answer"); answer4.setText(aAns.toCharArray(), 0, aAns.length()); Log.d("", selected[qIndex] + ""); if (selected[qIndex] == 0) answers.check(R.id.a0); if (selected[qIndex] == 1) answers.check(R.id.a1); if (selected[qIndex] == 2) answers.check(R.id.a2); if (selected[qIndex] == 3) answers.check(R.id.a3); setScoreTitle(); if (quesIndex == (QuizFunActivity.getQuesList().length() - 1)) next.setEnabled(false); if (quesIndex == 0) prev.setEnabled(false); if (quesIndex > 0) prev.setEnabled(true); if (quesIndex < (QuizFunActivity.getQuesList().length() - 1)) next.setEnabled(true); if (review) { Log.d("review", selected[qIndex] + "" + correctAns[qIndex]); ; if (selected[qIndex] != correctAns[qIndex]) { if (selected[qIndex] == 0) answer1.setTextColor(Color.RED); if (selected[qIndex] == 1) answer2.setTextColor(Color.RED); if (selected[qIndex] == 2) answer3.setTextColor(Color.RED); if (selected[qIndex] == 3) answer4.setTextColor(Color.RED); } if (correctAns[qIndex] == 0) answer1.setTextColor(Color.GREEN); if (correctAns[qIndex] == 1) answer2.setTextColor(Color.GREEN); if (correctAns[qIndex] == 2) answer3.setTextColor(Color.GREEN); if (correctAns[qIndex] == 3) answer4.setTextColor(Color.GREEN); } } catch (Exception e) { Log.e(this.getClass().toString(), e.getMessage(), e.getCause()); } }
/** * * 初始化item状态 * * <pre>方法 </pre> */ private void initRadioButtonStatus() { rbtn_keyword_full.setTextColor(Color.BLACK); rbtn_keyword_position_name.setTextColor(Color.BLACK); rbtn_keyword_enterprise_name.setTextColor(Color.BLACK); }
public void setRBColor(RadioButton white, RadioButton gray1, RadioButton gray2) { white.setTextColor(Color.parseColor("#FFffffff")); gray1.setTextColor(Color.parseColor("#FF666666")); gray2.setTextColor(Color.parseColor("#FF666666")); }
/** * 加载每一行的单选按钮 * * @param layoutMain * @param line * @param lineNum */ private void addLine( LinearLayout layoutMain, int line, int lineNum, int isDanNum, int danTeamNum, int teamNum, final boolean isBeijing) { LinearLayout layoutOne = new LinearLayout(context); int id = 0; int last = getNum(teamNum - 1, true); boolean isCheck = isLastCheck(teamNum, danTeamNum); for (int j = 0; j < lineNum; j++) { id = line * this.LineNum + j; RadioButton radio = new RadioButton(context); if (id < isDanNum) { radio.setEnabled(false); radio.setTextColor(Color.GRAY); radio.setButtonDrawable(R.drawable.radio_select); } else if (!isCheck && id >= last) { radio.setEnabled(false); radio.setTextColor(Color.GRAY); radio.setButtonDrawable(R.drawable.radio_select); } else { radio.setTextColor(Color.BLACK); radio.setButtonDrawable(R.drawable.radio_select); } if (isBeijing) { radio.setText(beijingTextId[id]); } else { radio.setText(radioTextId[id]); } int width = PublicMethod.getDisplayWidth(context); if (width == 720) { radio.setTextSize(PublicMethod.getPxInt(7, context)); } else if (width == 640) { radio.setTextSize(PublicMethod.getPxInt(7, context)); } else if (width == 240) { radio.setTextSize(PublicMethod.getPxInt(20, context)); } else if (width == 320) { radio.setTextSize(PublicMethod.getPxInt(15, context)); } else if (width == 800) { radio.setTextSize(PublicMethod.getPxInt(8, context)); } else { radio.setTextSize(PublicMethod.getPxInt(10, context)); } if (Constants.SCREEN_HEIGHT == 854) { radio.setTextSize(PublicMethod.getPxInt(8, context)); } radio.setId(id); radio.setPadding(PublicMethod.getPxInt(20, context), 0, 0, 0); int withPx = PublicMethod.getPxInt(75, context); // 将dip换算成px radio.setLayoutParams(new LayoutParams(withPx, LayoutParams.WRAP_CONTENT)); radio.setOnCheckedChangeListener( new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (isBeijing) { ((BeiJingSingleGameIndentActivity) context).bettingNum = getBeijingRadioZhu(buttonView.getText().toString()); ((BeiJingSingleGameIndentActivity) context).setBettingInformationShow(); } else { touzhuDialog.zhuShu = getRadioZhu(buttonView.getText().toString()); touzhuDialog.setAlertText(); setRadioPrize(buttonView.getText().toString()); } clearRadio(buttonView); } } }); radioBtns.add(radio); layoutOne.addView(radio); } layoutMain.addView(layoutOne); }
@Override public void initShowDate( final ViewHolderUtil viewHolder, final Standard_CK_Table_Item t, int position) { viewHolder.setText(R.id.txt_item_description, t.getItem_description()); if (t.getItem_repairType() != null && !t.getItem_repairType().equals("")) { if (t.getItem_repairType().equals("L")) { viewHolder.setText(R.id.txt_item_repairType, "限期整改"); viewHolder.setTextColor(R.id.txt_item_repairType, Color.rgb(253, 113, 0)); viewHolder.setText(R.id.txt_item_repairLimit, t.getItem_repairLimit()); viewHolder.setTextColor(R.id.txt_item_repairLimit, Color.rgb(253, 113, 0)); } else { viewHolder.setText(R.id.txt_item_repairType, "立即整改"); viewHolder.setTextColor(R.id.txt_item_repairType, Color.RED); viewHolder.setText(R.id.txt_item_repairLimit, "无"); } } else { viewHolder.setText(R.id.txt_item_repairLimit, "无"); viewHolder.setText(R.id.txt_item_repairLimit, "无"); } final RadioGroup rg_isok = (RadioGroup) viewHolder.getMconvertView().findViewById(R.id.rg_isok); final RadioButton rb_ck_stand_yes = (RadioButton) viewHolder.getMconvertView().findViewById(R.id.rb_ck_stand_yes); final RadioButton rb_ck_stand_no = (RadioButton) viewHolder.getMconvertView().findViewById(R.id.rb_ck_stand_no); rg_isok.setOnCheckedChangeListener(null); rg_isok.clearCheck(); rb_ck_stand_yes.setTextColor(Color.parseColor("#FF7D899D")); rb_ck_stand_no.setTextColor(Color.parseColor("#FF7D899D")); viewHolder.setRadioButtonCkecked(R.id.rb_ck_stand_yes, false); viewHolder.setRadioButtonCkecked(R.id.rb_ck_stand_no, false); if (t.getItem_reviewResult() != null && !t.getItem_reviewResult().equals("")) { if (t.getItem_reviewResult().equals("YES")) { viewHolder.setRadioButtonCkecked(R.id.rb_ck_stand_yes, true); rb_ck_stand_yes.setTextColor(Color.parseColor("#28aae1")); } else { viewHolder.setRadioButtonCkecked(R.id.rb_ck_stand_no, true); rb_ck_stand_no.setTextColor(Color.parseColor("#28aae1")); } } RelativeLayout rel_standitem_measure = viewHolder.getView(R.id.rel_standitem_measure); rel_standitem_measure.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub AlertDialog.Builder builder = new AlertDialog.Builder(mContext); // 先得到构造器 builder.setTitle("整改措施"); // 设置标题 builder.setMessage(t.getItem_repairMethod()); // 设置内容 builder.setIcon(R.drawable.note_stand48); // 设置图标,图片id即可 builder.setNegativeButton( "取消", new DialogInterface.OnClickListener() { // 设置取消按钮 @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); // 参数都设置完成了,创建并显示出来 builder.create().show(); } }); RelativeLayout rel_standitem_condition = viewHolder.getView(R.id.rel_standitem_condition); rel_standitem_condition.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub AlertDialog.Builder builder = new AlertDialog.Builder(mContext); // 先得到构造器 builder.setTitle("整改情况"); // 设置标题 builder.setMessage(t.getItem_repairCondition()); // 设置内容 builder.setIcon(R.drawable.note_stand48); // 设置图标,图片id即可 builder.setNegativeButton( "取消", new DialogInterface.OnClickListener() { // 设置取消按钮 @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); // 参数都设置完成了,创建并显示出来 builder.create().show(); } }); rg_isok.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub int radioButtonId = group.getCheckedRadioButtonId(); RadioButton rb = (RadioButton) viewHolder.getMconvertView().findViewById(radioButtonId); rb_ck_stand_yes.setTextColor(Color.parseColor("#FF7D899D")); rb_ck_stand_no.setTextColor(Color.parseColor("#FF7D899D")); rb.setTextColor(Color.parseColor("#28aae1")); if (mApcceptOpinionListener != null) { switch (radioButtonId) { case R.id.rb_ck_stand_yes: mApcceptOpinionListener.setItenApcceptOpinion(t, true); break; case R.id.rb_ck_stand_no: mApcceptOpinionListener.setItenApcceptOpinion(t, false); break; default: break; } } } }); }