android.widget.RadioGroup.OnCheckedChangeListener Java Examples
The following examples show how to use
android.widget.RadioGroup.OnCheckedChangeListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SetupWizardNumberOfSwitchesFragment.java From talkback with Apache License 2.0 | 6 votes |
/** * Add the appropriate action to update the shared preferences to the radio buttons in this view. */ @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); RadioGroup numberOfSwitchesRadioGroup = view.findViewById(R.id.number_of_switches_radio_group); OnCheckedChangeListener numberOfSwitchesChangeListener = (radioGroup, checkedId) -> { if (checkedId == R.id.one_switch_radio_button) { SwitchAccessPreferenceUtils.setAutoScanEnabled(getActivity(), true); } else if (checkedId == R.id.two_switches_radio_button) { SwitchAccessPreferenceUtils.setAutoScanEnabled(getActivity(), false); } }; numberOfSwitchesRadioGroup.setOnCheckedChangeListener(numberOfSwitchesChangeListener); /* Call change listener to capture the default highlighted radio button. */ numberOfSwitchesChangeListener.onCheckedChanged( numberOfSwitchesRadioGroup, numberOfSwitchesRadioGroup.getCheckedRadioButtonId()); }
Example #2
Source File: RegisterActivity.java From yiim_v2 with GNU General Public License v2.0 | 6 votes |
@Override protected void installListeners() { // TODO Auto-generated method stub mSexRadioGroup .setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub if (checkedId == R.id.register_sex_female) { mSex = Const.FEMALE; } else { mSex = Const.MALE; } } }); }
Example #3
Source File: TestActivity.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Log.e(Constants.LOG, "onCreate called"); } super.onCreate(savedInstanceState); setContentView(R.layout.main); RadioGroup group1 = (RadioGroup) findViewById(R.id.orientation); group1.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.horizontal: group.setOrientation(LinearLayout.HORIZONTAL); break; case R.id.vertical: group.setOrientation(LinearLayout.VERTICAL); break; } } }); }
Example #4
Source File: X8CameraItemArrayController.java From FimiX8-RE with MIT License | 5 votes |
public void initActions() { this.x8RgCameraResolution.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup radioGroup, int i) { String systemType = X8CameraItemArrayController.this.x8CameraParamsValue.getCurParamsJson().getSystem_type(); if (R.id.x8_rbtn_4k == i) { if (systemType.equals("PAL")) { X8CameraItemArrayController.this.cameraManager.setCameraKeyParams(X11CmdConstants.VALUE_VIDEO_RESOLUTION_2160P_25F_PAL_4K, "video_resolution", X8CameraItemArrayController.this); } else { X8CameraItemArrayController.this.cameraManager.setCameraKeyParams("3840x2160 30P 16:9", "video_resolution", X8CameraItemArrayController.this); } } else if (R.id.x8_rbtn_2_5k == i) { if (systemType.equals("PAL")) { X8CameraItemArrayController.this.cameraManager.setCameraKeyParams("2560x1440 25P 16:9", "video_resolution", X8CameraItemArrayController.this); } else { X8CameraItemArrayController.this.cameraManager.setCameraKeyParams(CameraJsonCollection.VALUE_VIDEO_RESOLUTION_1440P_60F_2K, "video_resolution", X8CameraItemArrayController.this); } } else if (R.id.x8_rbtn_1080p != i) { } else { if (systemType.equals("PAL")) { X8CameraItemArrayController.this.cameraManager.setCameraKeyParams("1920x1080 25P 16:9", "video_resolution", X8CameraItemArrayController.this); } else { X8CameraItemArrayController.this.cameraManager.setCameraKeyParams("1920x1080 30P 16:9", "video_resolution", X8CameraItemArrayController.this); } } } }); }
Example #5
Source File: SetupWizardScanningMethodFragment.java From talkback with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); RadioGroup scanningMethodRadioGroup = view.findViewById(R.id.scanning_options_radio_group); OnCheckedChangeListener scanningMethodChangeListener = new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int checkedId) { if (checkedId == R.id.group_selection_radio_button) { SwitchAccessPreferenceUtils.setScanningMethod( getActivity(), R.string.group_selection_key); } else if (checkedId == R.id.row_column_scanning_radio_button) { SwitchAccessPreferenceUtils.setScanningMethod( getActivity(), R.string.row_col_scanning_key); } else if (checkedId == R.id.linear_scanning_except_keyboard_radio_button) { SwitchAccessPreferenceUtils.setScanningMethod( getActivity(), R.string.views_linear_ime_row_col_key); } else if (checkedId == R.id.linear_scanning_radio_button) { SwitchAccessPreferenceUtils.setScanningMethod( getActivity(), R.string.linear_scanning_key); } } }; scanningMethodRadioGroup.setOnCheckedChangeListener(scanningMethodChangeListener); /* Call change listener to capture the default highlighted radio button. */ scanningMethodChangeListener.onCheckedChanged( scanningMethodRadioGroup, scanningMethodRadioGroup.getCheckedRadioButtonId()); }
Example #6
Source File: MarkerDemoActivity.java From android-samples with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.marker_demo); mTopText = (TextView) findViewById(R.id.top_text); mRotationBar = (SeekBar) findViewById(R.id.rotationSeekBar); mRotationBar.setMax(360); mRotationBar.setOnSeekBarChangeListener(this); mFlatBox = (CheckBox) findViewById(R.id.flat); mOptions = (RadioGroup) findViewById(R.id.custom_info_window_options); mOptions.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (mLastSelectedMarker != null && mLastSelectedMarker.isInfoWindowShown()) { // Refresh the info window when the info window's content has changed. mLastSelectedMarker.showInfoWindow(); } } }); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); new OnMapAndViewReadyListener(mapFragment, this); }
Example #7
Source File: MarkerDemoActivity.java From android-samples with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.marker_demo); mTopText = (TextView) findViewById(R.id.top_text); mRotationBar = (SeekBar) findViewById(R.id.rotationSeekBar); mRotationBar.setMax(360); mRotationBar.setOnSeekBarChangeListener(this); mFlatBox = (CheckBox) findViewById(R.id.flat); mOptions = (RadioGroup) findViewById(R.id.custom_info_window_options); mOptions.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (mLastSelectedMarker != null && mLastSelectedMarker.isInfoWindowShown()) { // Refresh the info window when the info window's content has changed. mLastSelectedMarker.showInfoWindow(); } } }); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); new OnMapAndViewReadyListener(mapFragment, this); }
Example #8
Source File: MainActivity.java From reader with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // ���ļ��в����� ���ȴ����ļ��� File path = new File(IMG_PATH); if (!path.exists()) { path.mkdirs(); } tvResult = (TextView) findViewById(R.id.tv_result); ivSelected = (ImageView) findViewById(R.id.iv_selected); ivTreated = (ImageView) findViewById(R.id.iv_treated); btnCamera = (Button) findViewById(R.id.btn_camera); btnSelect = (Button) findViewById(R.id.btn_select); chPreTreat = (CheckBox) findViewById(R.id.ch_pretreat); radioGroup = (RadioGroup) findViewById(R.id.radiogroup); btnCamera.setOnClickListener(new cameraButtonListener()); btnSelect.setOnClickListener(new selectButtonListener()); // �������ý������� radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.rb_en: LANGUAGE = "eng"; break; case R.id.rb_ch: LANGUAGE = "chi_sim"; break; } } }); }
Example #9
Source File: MainActivity.java From PacketCaptureTool with Eclipse Public License 1.0 | 5 votes |
private void setFragmentIndicator() { rdgrpBottomMenu = (RadioGroup) findViewById(R.id.rdgrpBottomMenu); rdgrpBottomMenu.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { fragmentTransaction = fragmentManager.beginTransaction() .hide(fragments[0]).hide(fragments[1]).hide(fragments[2]); switch (checkedId) { case R.id.rdbttnCapture: fragmentTransaction.show(fragments[0]).commit(); break; case R.id.rdbttnAnalyze: fragmentTransaction.show(fragments[1]).commit(); break; case R.id.rdbttnMore: fragmentTransaction.show(fragments[2]).commit(); break; default: break; } } }); }
Example #10
Source File: MainActivity.java From RatioImageView with The Unlicense | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RadioGroup radios = (RadioGroup) findViewById(R.id.options); radios.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.ratio: setupGrid(R.layout.grid_item_ratio); break; case R.id.scale: setupGrid(R.layout.grid_item_scale); break; default: setupGrid(R.layout.grid_item); break; } } }); setupGrid(R.layout.grid_item); }
Example #11
Source File: TopRecommendFragment.java From letv with Apache License 2.0 | 4 votes |
private void findView() { int width = UIs.getScreenWidth(); int height = UIs.getScreenHeight(); this.gallerySwitchLayout = (LinearLayout) this.root.findViewById(R.id.home_content_gallery_switch); this.focusGallery = (LetvGallery) this.root.findViewById(R.id.top_gallery); this.focusGallery.getLayoutParams().height = UIs.zoomWidth(getResources().getDimensionPixelSize(2131165538)); this.listView1 = (ListView) this.root.findViewById(R.id.listview1); this.listView2 = (ListView) this.root.findViewById(R.id.listview2); this.listView3 = (ListView) this.root.findViewById(R.id.listview3); this.galleryAdapter = new RecommGalleryAdapter(getActivity()); this.listAdapter1 = new RecommendlListViewAdapter(getActivity(), 1); this.listAdapter2 = new RecommendlListViewAdapter(getActivity(), 2); this.listAdapter3 = new RecommendlListViewAdapter(getActivity(), 3); this.listView1.setAdapter(this.listAdapter1); this.listView2.setAdapter(this.listAdapter2); this.listView3.setAdapter(this.listAdapter3); this.focusGallery.setAdapter(this.galleryAdapter); this.focusGallery.setOnItemSelectedListener(new GalleryItemSelectedEvent()); this.tableGroup = (RadioGroup) this.root.findViewById(R.id.table); this.radio1 = (RadioButton) this.root.findViewById(R.id.radiobtn1); this.radio2 = (RadioButton) this.root.findViewById(R.id.radiobtn2); this.radio3 = (RadioButton) this.root.findViewById(R.id.radiobtn3); this.tableGroup.check(new int[]{R.id.radiobtn1, R.id.radiobtn2, R.id.radiobtn3}[selectedType]); this.listView1.setVisibility(0); this.tableGroup.setOnCheckedChangeListener(new OnCheckedChangeListener(this) { int current; final /* synthetic */ TopRecommendFragment this$0; { if (HotFix.PREVENT_VERIFY) { System.out.println(VerifyLoad.class); } this.this$0 = this$0; this.current = 1; } public void onCheckedChanged(RadioGroup group, int checkedId) { String tag = null; switch (checkedId) { case R.id.radiobtn1 /*2131362725*/: if (TopRecommendFragment.selectedType != 0) { TopRecommendFragment.selectedType = 0; this.this$0.listView1.setVisibility(0); this.this$0.listView2.setVisibility(8); this.this$0.listView3.setVisibility(8); if (this.this$0.listAdapter1.getList() == null || this.this$0.listAdapter1.getList().size() <= 0) { this.current = this.this$0.currentPage; tag = (String) this.this$0.radio1.getTag(); break; } return; } return; case R.id.radiobtn2 /*2131362726*/: if (TopRecommendFragment.selectedType != 1) { TopRecommendFragment.selectedType = 1; this.this$0.listView2.setVisibility(0); this.this$0.listView3.setVisibility(8); this.this$0.listView1.setVisibility(8); if (this.this$0.listAdapter2.getList() == null || this.this$0.listAdapter2.getList().size() <= 0) { this.current = this.this$0.currentPage2; tag = (String) this.this$0.radio2.getTag(); break; } return; } return; break; case R.id.radiobtn3 /*2131362727*/: if (TopRecommendFragment.selectedType != 2) { TopRecommendFragment.selectedType = 2; this.this$0.listView3.setVisibility(0); this.this$0.listView2.setVisibility(8); this.this$0.listView1.setVisibility(8); if (this.this$0.listAdapter3.getList() == null || this.this$0.listAdapter3.getList().size() <= 0) { tag = (String) this.this$0.radio3.getTag(); this.current = this.this$0.currentPage3; break; } return; } return; } if (tag != null && !"".equals(tag)) { this.this$0.exchid = tag; this.this$0.requestTask = new RequestRecommendDataTask(this.this$0, this.this$0.getActivity(), this.current); this.this$0.requestTask.start(); } } }); this.listView1.setOnScrollListener(new ScrollEvent(this, this.listAdapter1, this.listView1, this.currentPage, this.totalNum)); this.listView2.setOnScrollListener(new ScrollEvent(this, this.listAdapter2, this.listView2, this.currentPage2, this.totalNum)); this.listView3.setOnScrollListener(new ScrollEvent(this, this.listAdapter3, this.listView3, this.currentPage3, this.totalNum)); }
Example #12
Source File: MidiInputCreateDialog.java From PdDroidPublisher with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle("IP MIDI Input creation"); LinearLayout view = new LinearLayout(getContext()); view.setOrientation(LinearLayout.VERTICAL); RadioGroup rg = new RadioGroup(getContext()); final RadioButton rbMulticast = new RadioButton(getContext()); rbMulticast.setText("RAW/Multicast"); final RadioButton rbUnicast = new RadioButton(getContext()); rbUnicast.setText("RAW/Unicast"); rg.addView(rbUnicast); rg.addView(rbMulticast); rbUnicast.setChecked(true); final EditText tvIP = new EditText(getContext()); tvIP.setText("127.0.0.1"); tvIP.setEnabled(rbMulticast.isChecked()); final EditText tvPORT = new EditText(getContext()); tvPORT.setInputType(InputType.TYPE_CLASS_NUMBER); tvPORT.setText("21929"); Button btOk = new Button(getContext()); btOk.setText("Create"); rg.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int checkedId) { tvIP.setEnabled(rbMulticast.isChecked()); } }); btOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { IPMidiInput input = new IPMidiInput(); input.multicast = rbMulticast.isChecked(); input.ip = rbMulticast.isChecked() ? tvIP.getText().toString() : null; input.port = Integer.parseInt(tvPORT.getText().toString()); device.inputs.add(input); MidiInputCreateDialog.this.dismiss(); } }); view.addView(rg); view.addView(tvIP); view.addView(tvPORT); view.addView(btOk); setContentView(view); }
Example #13
Source File: IndexActivity.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
private void findViews() { mDeviceRb = (RadioButton) findViewById(R.id.main_tab_devices); mContentRb = (RadioButton) findViewById(R.id.main_tab_content); mControlRb = (RadioButton) findViewById(R.id.main_tab_control); mSettingsRb = (RadioButton) findViewById(R.id.main_tab_settings); mTabHost = this.getTabHost(); TabHost.TabSpec spec; Intent intent; intent = new Intent().setClass(this, DevicesActivity.class); spec = mTabHost.newTabSpec(getString(R.string.device)) .setIndicator(getString(R.string.device)).setContent(intent); mTabHost.addTab(spec); intent = new Intent().setClass(this, ContentActivity.class); spec = mTabHost.newTabSpec(getString(R.string.content)) .setIndicator(getString(R.string.content)).setContent(intent); mTabHost.addTab(spec); intent = new Intent().setClass(this, ControlActivity.class); spec = mTabHost.newTabSpec(getString(R.string.control)) .setIndicator(getString(R.string.control)).setContent(intent); mTabHost.addTab(spec); intent = new Intent().setClass(this, SettingActivity.class); spec = mTabHost.newTabSpec(getString(R.string.setting)) .setIndicator(getString(R.string.setting)).setContent(intent); mTabHost.addTab(spec); mTabHost.setCurrentTab(0); RadioGroup radioGroup = (RadioGroup) this .findViewById(R.id.main_tab_group); radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub switch (checkedId) { case R.id.main_tab_devices: mTabHost.setCurrentTabByTag(getString(R.string.device)); break; case R.id.main_tab_content: mTabHost.setCurrentTabByTag(getString(R.string.content)); break; case R.id.main_tab_control: mTabHost.setCurrentTabByTag(getString(R.string.control)); break; case R.id.main_tab_settings: mTabHost.setCurrentTabByTag(getString(R.string.setting)); break; default: break; } } }); }
Example #14
Source File: UrlConfigActivity.java From freeiot-android with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_url_config); mUrlRadioGroup = (RadioGroup) findViewById(R.id.radio_group); mDevRadioBtn = (RadioButton) mUrlRadioGroup.findViewById(R.id.dev_radio); mPreProductRadioBtn = (RadioButton) mUrlRadioGroup.findViewById(R.id.pre_product_radio); mReleaseRadioBtn = (RadioButton) mUrlRadioGroup.findViewById(R.id.release_radio); findViewById(R.id.back).setOnClickListener(this); if (UrlConfigManager.getCurrentState() == UrlConfigManager.DEVELOP_STATE) { mDevRadioBtn.setChecked(true); } else if (UrlConfigManager.getCurrentState() == UrlConfigManager.PREPRODUCT_STATE) { mPreProductRadioBtn.setChecked(true); } else if (UrlConfigManager.getCurrentState() == UrlConfigManager.RELEASE_STATE) { mReleaseRadioBtn.setChecked(true); } mApiHostUrlView = (TextView)findViewById(R.id.tv_apihost_url); setData(); mUrlRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.dev_radio: UrlConfigManager.setCurrentState(UrlConfigManager.DEVELOP_STATE); break; case R.id.pre_product_radio: UrlConfigManager.setCurrentState(UrlConfigManager.PREPRODUCT_STATE); break; case R.id.release_radio: UrlConfigManager.setCurrentState(UrlConfigManager.RELEASE_STATE); break; default: break; } UrlConfigManager.updateUrl(UrlConfigManager.getCurrentState()); AppConfigPrefs.getInstances(UrlConfigActivity.this).saveIntValue("cur_env", UrlConfigManager.getCurrentState()); setData(); } }); }
Example #15
Source File: ChatActivity.java From weixin with Apache License 2.0 | 4 votes |
/** * 设置笑脸被点击后的表情数据 */ private void setSmilingfaceData() { mV_myScrollView = new MyScrollView(this); mList_emoji = FaceConversionUtil.getInstace().emojiLists; // 添加表情页 mList_emojiAdapter = new ArrayList<EmojiAdapter>(); mV_myScrollView.removeAllViews(); for (int i = 0; i < mList_emoji.size(); i++) { // GridView的一些特殊属性: // // 1.android:numColumns=”auto_fit” //GridView的列数设置为自动 // 2.android:columnWidth=”90dp " //每列的宽度,也就是Item的宽度 // 3.android:stretchMode=”columnWidth"//缩放与列宽大小同步 // 4.android:verticalSpacing=”10dp” //两行之间的边距 // 5.android:horizontalSpacing=”10dp” //两列之间的边距 // 6.android:cacheColorHint="#00000000" //去除拖动时默认的黑色背景 // 7.android:listSelector="#00000000" //去除选中时的黄色底色 // 8.android:scrollbars="none" //隐藏GridView的滚动条 // 9.android:fadeScrollbars="true" //设置为true就可以实现滚动条的自动隐藏和显示 // 10.android:fastScrollEnabled="true" //GridView出现快速滚动的按钮(至少滚动4页才会显示) // 11.android:fadingEdge="none" //GridView衰落(褪去)边缘颜色为空,缺省值是vertical。(可以理解为上下边缘的提示色) // 12.android:fadingEdgeLength="10dip" //定义的衰落(褪去)边缘的长度 // 13.android:stackFromBottom="true" //设置为true时,你做好的列表就会显示你列表的最下面 // 14.android:transcriptMode="alwaysScroll" //当你动态添加数据时,列表将自动往下滚动最新的条目可以自动滚动到可视范围内 // 15.android:drawSelectorOnTop="false" //点击某条记录不放,颜色会在记录的后面成为背景色,内容的文字可见(缺省为false) // GridView view = new GridView(this); EmojiAdapter adapter = new EmojiAdapter(this, mList_emoji.get(i)); view.setAdapter(adapter); mList_emojiAdapter.add(adapter); view.setOnItemClickListener(this); view.setNumColumns(7); view.setBackgroundColor(Color.TRANSPARENT); // view.setHorizontalSpacing(1); //两列之间的边距 // view.setVerticalSpacing(10);//两行之间的边距 view.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);//缩放与列宽大小同步 view.setCacheColorHint(0);//去除拖动时默认的黑色背景 // view.setPadding(5, 5, 5, 5); view.setSelector(new ColorDrawable(Color.TRANSPARENT)); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); view.setLayoutParams(params); view.setGravity(Gravity.CENTER); mV_myScrollView.addView(view); } mLl_chat_smilingface_body.removeAllViews(); mLl_chat_smilingface_body.addView(mV_myScrollView);//将MyScrollView添加到内容显示区 RadioGroup.LayoutParams params_rb = new RadioGroup.LayoutParams(DensityUtil.dip2px(this, 8), DensityUtil.dip2px(this, 8)); int marginValue = DensityUtil.dip2px(this, 3); params_rb.setMargins(marginValue, 0, marginValue, 0); for (int i = 0; i < mV_myScrollView.getChildCount(); i++) { RadioButton rbtn = new RadioButton(this); rbtn.setButtonDrawable(R.drawable.cgt_selector_chat_radiobtn_bg); rbtn.setId(i); mRg_chat_smilingface_tab.addView(rbtn, params_rb); if (i == 0) { rbtn.setChecked(true); } } /** * 监听单选按钮是否被选中, */ mRg_chat_smilingface_tab.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { current = checkedId; mV_myScrollView.moveToDest(checkedId); } }); /** * */ mV_myScrollView.setChangedListener(new IPageChangedListener() { @Override public void changedTo(int pageId) { current = pageId; ((RadioButton) mRg_chat_smilingface_tab.getChildAt(pageId)).setChecked(true); } }); }