android.widget.RadioGroup Java Examples

The following examples show how to use android.widget.RadioGroup. 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: SettingActivity.java    From KSYMediaPlayer_Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
    if(i==R.id.use_hw){
        editor.putString("choose_decode", Settings.USEHARD);
    }else if(i==R.id.use_sw){
        editor.putString("choose_decode", Settings.USESOFT);
    }else if(i==R.id.type_vod){
        editor.putString("choose_type", Settings.VOD);
    }else if(i==R.id.type_live){
        editor.putString("choose_type", Settings.LIVE);
    }else if(i==R.id.type_floating){
        editor.putString("choose_type", Settings.FLOATING);
    }else if(i==R.id.type_media_player){
        editor.putString("choose_type", Settings.MEDIA_PLAYER);
    }
    editor.commit();
}
 
Example #2
Source File: MarketDetailActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    switch (checkedId) {
        case R.id.rb_one_minute:
            loadKlineData(KlineTimeType.ONE_MINUTE);
            break;
        case R.id.rb_five_minute:
            loadKlineData(KlineTimeType.FIVE_MINUTES);
            break;
        case R.id.rb_one_hour:
            loadKlineData(KlineTimeType.ONE_HOUR);
            break;
        case R.id.rb_one_day:
            loadKlineData(KlineTimeType.ONE_DAY);
            break;
        default:
            break;
    }
}
 
Example #3
Source File: ColorSpaceProcessor.java    From Camdroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = super
            .onCreateView(inflater, container, savedInstanceState);

    RadioGroup colorspace = (RadioGroup) v.findViewById(R.id.colorspace);
    colorspace.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            channel = checkedId;
        }
    });

    ((RadioButton) v.findViewById(channel)).setChecked(true);

    return v;
}
 
Example #4
Source File: BackupActivity.java    From LaunchTime with GNU General Public License v3.0 6 votes vote down vote up
private RadioButton makeRadioButton(RadioGroup baks, final String bk, final boolean item) {
    RadioButton bkb = new RadioButton(this);
    bkb.setText(bk);


    bkb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                selectedBackup = bk;
                selected = item;
                Log.d("backuppage", "selected = " + selectedBackup);
                backupSelected(selected);
            }
        }
    });

    baks.addView(bkb);
    return bkb;
}
 
Example #5
Source File: AdvancedUseActivity.java    From file-downloader with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.advanced_use__activity_advanced_use);

    // init fragments
    List<Fragment> pagerFragments = new ArrayList<Fragment>();
    Fragment fragment1 = CoursePreviewFragment.newInstance();
    pagerFragments.add(fragment1);
    Fragment fragment2 = CourseDownloadFragment.newInstance();
    pagerFragments.add(fragment2);

    mFragmentActionTabPager = new FragmentActionTabPager(getSupportFragmentManager(), pagerFragments);

    RadioGroup rgActionTab = (RadioGroup) findViewById(R.id.rgActionTab);
    ActionTabViewPager avPagerContainer = (ActionTabViewPager) findViewById(R.id.atViewPager);
    mFragmentActionTabPager.setup(rgActionTab, avPagerContainer, true, false);
}
 
Example #6
Source File: SimpleExtractor.java    From AndroidRipper with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Detect Name of the Widget
 * 
 * @param v
 *            Widget
 * @return
 */
protected String detectName(View v) {
	String name = "";
	if (v instanceof TextView) {
		TextView t = (TextView) v;
		name = (t.getText() != null) ? t.getText().toString() : "";
		if (v instanceof EditText) {
			CharSequence hint = ((EditText) v).getHint();
			name = (hint == null) ? "" : hint.toString();
		}
	} else if (v instanceof RadioGroup) {
		RadioGroup g = (RadioGroup) v;
		int max = g.getChildCount();
		String text = "";
		for (int i = 0; i < max; i++) {
			View c = g.getChildAt(i);
			text = detectName(c);
			if (!text.equals("")) {
				name = text;
				break;
			}
		}
	}
	return name;
}
 
Example #7
Source File: ReflectionExtractor.java    From AndroidRipper with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Detect Name of the Widget
 * 
 * @param v
 *            Widget
 * @return
 */
protected String detectName(View v) {
	String name = "";
	if (v instanceof TextView) {
		TextView t = (TextView) v;
		name = (t.getText() != null) ? t.getText().toString() : "";
		if (v instanceof EditText) {
			CharSequence hint = ((EditText) v).getHint();
			name = (hint == null) ? "" : hint.toString();
		}
	} else if (v instanceof RadioGroup) {
		RadioGroup g = (RadioGroup) v;
		int max = g.getChildCount();
		String text = "";
		for (int i = 0; i < max; i++) {
			View c = g.getChildAt(i);
			text = detectName(c);
			if (!text.equals("")) {
				name = text;
				break;
			}
		}
	}
	return name;
}
 
Example #8
Source File: WrapLayoutActivity.java    From ProjectX with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setSupportActionBar(R.id.wl_toolbar);
    mVContent = findViewById(R.id.wl_wl_content);
    final RadioGroup gravity = findViewById(R.id.wl_rg_gravity);
    final SeekBar horizontal = findViewById(R.id.wl_sb_horizontal);
    final SeekBar vertical = findViewById(R.id.wl_sb_vertical);

    gravity.setOnCheckedChangeListener(this);
    gravity.check(R.id.wl_rb_top);
    horizontal.setOnSeekBarChangeListener(this);
    horizontal.setProgress(15);
    vertical.setOnSeekBarChangeListener(this);
    vertical.setProgress(15);
}
 
Example #9
Source File: AlarmItemDialog.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dialog_alarm_item);
    ButterKnife.bind(this);
    fillMap();
    mAlarmItemBtns.check(itemMaps.get(mAlarmItem));
    mAlarmItemBtns.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            RadioButton selectedBtn = (RadioButton) findViewById(checkedId);
            mAlarmItem = selectedBtn.getText().toString();
            if (mSelectedListener != null)
                mSelectedListener.onSelected(mAlarmItem);
            dismiss();
        }
    });
}
 
Example #10
Source File: SetupWizardStepSpeedFragment.java    From talkback with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateScreenForCurrentPreferenceValues(View view) {
  RadioGroup scanningMethodRadioGroup = view.findViewById(R.id.autoscan_speeds_radio_group);
  double autoScanDelay = SwitchAccessPreferenceUtils.getAutoScanDelaySeconds(getActivity());
  if (autoScanDelay
      == Double.parseDouble(getString(R.string.pref_auto_scan_time_delay_fast_value))) {
    scanningMethodRadioGroup.check(R.id.fast_speed_radio_button);
  } else if (autoScanDelay
      == Double.parseDouble(getString(R.string.pref_auto_scan_time_delay_medium_value))) {
    scanningMethodRadioGroup.check(R.id.medium_speed_radio_button);
  } else if (autoScanDelay
      == Double.parseDouble(getString(R.string.pref_auto_scan_time_delay_slow_value))) {
    scanningMethodRadioGroup.check(R.id.slow_speed_radio_button);
  } else {
    scanningMethodRadioGroup.check(R.id.custom_speed_radio_button);
    EditText editText = view.findViewById(R.id.custom_speed_edit_text);
    editText.setText(Double.toString(autoScanDelay));
  }
}
 
Example #11
Source File: SettingInfoActivity.java    From WifiChat with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void initViews() {

    mIvAvater = (ImageView) findViewById(R.id.setting_my_avater_img);
    mEtNickname = (EditText) findViewById(R.id.setting_my_nickname);
    mRgGender = (RadioGroup) findViewById(R.id.setting_baseinfo_rg_gender);
    mHtvConstellation = (TextView) findViewById(R.id.setting_birthday_htv_constellation);
    mHtvAge = (TextView) findViewById(R.id.setting_birthday_htv_age);
    mDpBirthday = (DatePicker) findViewById(R.id.setting_birthday_dp_birthday);

    mRbBoy = (RadioButton) findViewById(R.id.setting_baseinfo_rb_male);
    mRbGirl = (RadioButton) findViewById(R.id.setting_baseinfo_rb_female);

    mBtnBack = (Button) findViewById(R.id.setting_btn_back);
    mBtnNext = (Button) findViewById(R.id.setting_btn_next);

}
 
Example #12
Source File: MainActivity.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
protected void siteChanged(RadioGroup group, int checkedId) {
    if (checkedId == -1) {
        return;
    }
    RadioButton button = (RadioButton) group.findViewById(checkedId);
    Site site = (Site) button.getTag();
    if (site != null) {
        App.setSiteUrl(site.getUrl());
    }
    if (site == null) {
        group.clearCheck();
        openSettingsActivity();
    } else if (!site.getUrl().equals(mCurrentSiteUrl)) { // TODO 第一次启动 加载上次查看的url。
        mDrawerPosition = ListView.INVALID_POSITION;
        mCurrentSite = site;
        mCurrentSiteUrl = site.getUrl();
        PrefsUtils.setCurrentSiteUrl(mCurrentSiteUrl);
        App.setLogin(false);
        clearDatabase();
        // 登陆完成后,再加载其他信息
        loadUserInfo(site, false);
    } else {
        setupUserInfo(mUser);
    }
    getActionBar().setSubtitle(mCurrentSiteUrl);
}
 
Example #13
Source File: MainActivity.java    From AndroidWearable-Samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    mFutureQuestions = new PriorityQueue<Question>(10);

    // Find UI components to be used later.
    questionEditText = (EditText) findViewById(R.id.question_text);
    choiceAEditText = (EditText) findViewById(R.id.choice_a_text);
    choiceBEditText = (EditText) findViewById(R.id.choice_b_text);
    choiceCEditText = (EditText) findViewById(R.id.choice_c_text);
    choiceDEditText = (EditText) findViewById(R.id.choice_d_text);
    choicesRadioGroup = (RadioGroup) findViewById(R.id.choices_radio_group);
    quizStatus = (TextView) findViewById(R.id.quiz_status);
    quizButtons = (LinearLayout) findViewById(R.id.quiz_buttons);
    questionsContainer = (LinearLayout) findViewById(R.id.questions_container);
    readQuizFromFileButton = (Button) findViewById(R.id.read_quiz_from_file_button);
    resetQuizButton = (Button) findViewById(R.id.reset_quiz_button);
}
 
Example #14
Source File: MainActivity.java    From JNChartDemo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    RadioGroup navigation = (RadioGroup) findViewById(R.id.navigation);
    if (navigation != null) {
        navigation.setOnCheckedChangeListener(this);
    }

    btn1 = (RadioButton) findViewById(R.id.fragment1);
    btn2 = (RadioButton) findViewById(R.id.fragment2);
    btn3 = (RadioButton) findViewById(R.id.fragment3);
    btn4 = (RadioButton) findViewById(R.id.fragment4);

    fragment1 = new Fragment1();
    fragment2 = new Fragment2();
    fragment3 = new Fragment3();
    fragment4 = new Fragment4();

    getSupportFragmentManager().beginTransaction().add(R.id.home_container, fragment1).commit();
    mContent = fragment1;


}
 
Example #15
Source File: RecyclerItemOperationActivity.java    From androidexamples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main2);

    mRecyclerView = (RecyclerView) findViewById(R.id.alphaList);
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);

    mAdapter = new ClickableFruitAdapter(FruitData.getList1(), this);
    mRecyclerView.setAdapter(mAdapter);

    for (FruitData d : FruitData.getList2()) {
        mExtraFruits.add(d);
    }

    RadioGroup opGroup = (RadioGroup) findViewById(R.id.opGroup);
    opGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            mMode = i;
        }
    });

}
 
Example #16
Source File: NgChange.java    From ngAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void attach(Scope scope, View view, int layoutId, int viewId, Tuple<String, String>[] models){
    Executor executor = new Executor(scope, layoutId, viewId, getAttribute());
    if(view instanceof CompoundButton){
        CompoundButton button = (CompoundButton) view;
        button.setOnCheckedChangeListener(executor);
    }else if(view instanceof TextView){
        TextView textView = (TextView) view;
        textView.addTextChangedListener(executor);
    }else if(view instanceof Spinner){
        Spinner spinner = (Spinner) view;
        spinner.setOnItemSelectedListener(executor);
    }else if(view instanceof RadioGroup){
        RadioGroup group = (RadioGroup) view;
        group.setOnCheckedChangeListener(executor);
    }
}
 
Example #17
Source File: TestActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
/** 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 #18
Source File: SettingActivity.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
    ConfigInteracter interacter = new ConfigInteracter(this);
    if (group.getId() == R.id.group_zoom) {
        if (checkedId == R.id.radio_zoom_left) {
            interacter.setZoomControlsPosition(false);
        } else if (checkedId == R.id.radio_zoom_right) {
            interacter.setZoomControlsPosition(true);
        }
    } else if (group.getId() == R.id.group_mode) {
        if (checkedId == R.id.radio_white) {
            interacter.setNightMode(1);
        } else if (checkedId == R.id.radio_black) {
            if (BApp.TYPE_MAP == TypeMap.TYPE_BAIDU) {
                Toast.makeText(this, "夜间模式下百度地图可能需要重启应用后生效", Toast.LENGTH_LONG).show();
            }
            interacter.setNightMode(2);
        } else {
            interacter.setNightMode(0);
        }
        ((BApp) getApplication()).setNightMode();
    }

}
 
Example #19
Source File: HelloCameraActivity.java    From cameraMediaCodec with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void onCheckedChanged(RadioGroup group, int checkedId) {
	// TODO Auto-generated method stub
	switch (checkedId)
	{
	case R.id.RadioButton_surfaceview:
		Log.i(log_tag, "[Radio] RadioButton_surfaceview");
		mUseSurfaceTexture = false;
		break;
	case R.id.radioButton_surfacetexture:
		Log.i(log_tag, "[Radio] radioButton_surfacetexture");
		mUseSurfaceTexture = true;
		break;
	case R.id.RadioButton_AllocPB:
		Log.i(log_tag, "[Radio] RadioButton_AllocPB");
		mUsePreviewBuffer = true;
		break;
	case R.id.radioButton_NotAllocPB:
		Log.i(log_tag, "[Radio] radioButton_NotAllocPB");
		mUsePreviewBuffer = false;
		break;
	}
	
}
 
Example #20
Source File: PolylineCapControlFragment.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    if (polyline == null) {
        return;
    }

    int groupId = group.getId();
    if (groupId == R.id.start_cap_radio) {
        Cap startCap = radioIdToStartCap.get(checkedId);
        if (startCap != null) {
            polyline.setStartCap(startCap);
        }
    } else if (groupId == R.id.end_cap_radio) {
        Cap endCap = radioIdToEndCap.get(checkedId);
        if (endCap != null) {
            polyline.setEndCap(endCap);
        }
    }
}
 
Example #21
Source File: UiSettingsActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 初始化AMap对象
 */
private void init() {
	if (aMap == null) {
		aMap = mapView.getMap();
		mUiSettings = aMap.getUiSettings();
	}
	Button buttonScale = (Button) findViewById(R.id.buttonScale);
	buttonScale.setOnClickListener(this);
	CheckBox scaleToggle = (CheckBox) findViewById(R.id.scale_toggle);
	scaleToggle.setOnClickListener(this);
	CheckBox zoomToggle = (CheckBox) findViewById(R.id.zoom_toggle);
	zoomToggle.setOnClickListener(this);
	zoomRadioGroup = (RadioGroup) findViewById(R.id.zoom_position);
	zoomRadioGroup.setOnCheckedChangeListener(this);
	CheckBox compassToggle = (CheckBox) findViewById(R.id.compass_toggle);
	compassToggle.setOnClickListener(this);
	CheckBox mylocationToggle = (CheckBox) findViewById(R.id.mylocation_toggle);
	mylocationToggle.setOnClickListener(this);

}
 
Example #22
Source File: AsymmetricEncryptActivity.java    From BlogDemo with Apache License 2.0 6 votes vote down vote up
private void bindEvent() {
    ((TextView) findViewById(R.id.tv_title_bar_title)).setText(R.string.crypto_title_asymmetric);
    findViewById(R.id.iv_title_bar_back).setOnClickListener(this);
    mEtPublicKey = findViewById(R.id.et_crypto_public_key);
    mEtPrivateKey = findViewById(R.id.et_crypto_private_key);
    mEtData = findViewById(R.id.et_crypto_data);
    mEtResult = findViewById(R.id.et_crypto_result);
    findViewById(R.id.btn_crypto_rsa_encrypt).setOnClickListener(this);
    findViewById(R.id.btn_crypto_rsa_decrypt).setOnClickListener(this);
    ((RadioGroup) findViewById(R.id.rg_crypto_output_mode)).setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            mOutputModeCheckedId = checkedId;
        }
    });
}
 
Example #23
Source File: MainActivity.java    From WindView with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
    switch (radioGroup.getCheckedRadioButtonId()) {
        case R.id.rv_up:
            windView.setTrendType(TrendType.UP);
            windView.start();
            break;
        case R.id.rv_down:
            windView.setTrendType(TrendType.DOWN);
            windView.start();
            break;
        case R.id.rv_none:
            windView.setTrendType(TrendType.NONE);
            windView.start();
            break;
    }

}
 
Example #24
Source File: SearchActivity.java    From Car-Pooling with MIT License 6 votes vote down vote up
/**
 * This method is used to select ride that are available to specific destination in the form of radio buttons
 */
private void displayConfirmation(){

    RadioGroup radioGroup= (RadioGroup) findViewById(R.id.RadioButtonGroup);
    if(radioGroup.getChildCount()>0) {
        RadioButton radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId());
        String selectedtext = radioButton.getText().toString();
        Toast.makeText(SearchActivity.this, selectedtext, Toast.LENGTH_SHORT).show();

        //Toast.makeText(SearchActivity.this, text[5], Toast.LENGTH_SHORT).show();
        Intent myIntent = new Intent(this, RideConfirmation.class);
        myIntent.putExtra("RideDetails",selectedtext);
        myIntent.putExtra("PickupLocation",address);
        startActivityForResult(myIntent, 0);
        finish();

    }
    else
    {
        Toast.makeText(SearchActivity.this, "No Rides available to book.. Please try again", Toast.LENGTH_SHORT).show();
    }

}
 
Example #25
Source File: SettingActivity.java    From QNRTC-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    switch (group.getCheckedRadioButtonId()) {
        case R.id.maintain_res_button_yes:
            mMaintainResolution = true;
            break;
        case R.id.maintain_res_button_no:
            mMaintainResolution = false;
            break;
    }
}
 
Example #26
Source File: Dialog.java    From PocketMaps with MIT License 5 votes vote down vote up
public static void showUnitTypeSelector(Activity activity)
{
  AlertDialog.Builder builder1 = new AlertDialog.Builder(activity);
  builder1.setTitle(R.string.units);
  builder1.setCancelable(true);
  
  final RadioButton rb1 = new RadioButton(activity.getBaseContext());
  rb1.setText(R.string.units_metric);

  final RadioButton rb2 = new RadioButton(activity.getBaseContext());
  rb2.setText(R.string.units_imperal);
  
  final RadioGroup rg = new RadioGroup(activity.getBaseContext());
  rg.addView(rb1);
  rg.addView(rb2);
  rg.check(Variable.getVariable().isImperalUnit() ? rb2.getId() : rb1.getId());
  
  builder1.setView(rg);
  OnClickListener listener = new OnClickListener()
  {
    @Override
    public void onClick(DialogInterface dialog, int buttonNr)
    {
      Variable.getVariable().setImperalUnit(rb2.isChecked());
      Variable.getVariable().saveVariables(Variable.VarType.Base);
    }
  };
  builder1.setPositiveButton(R.string.ok, listener);
  AlertDialog alert11 = builder1.create();
  alert11.show();
}
 
Example #27
Source File: ZhiHuAdapter.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkId) {
    for (int i = 0; i < radioGroup.getChildCount(); i++) {
        if (radioGroup.getChildAt(i).getId() == checkId) {
            //  即将要展示的Fragment
            Fragment target = mFragmentList.get(i);
            Fragment currentFragment = getCurrentFragment();
            currentFragment.onPause();

            FragmentTransaction fragmentTransaction = getFragmentTransaction();
            if (target.isAdded()) {
                target.onResume();
                fragmentTransaction.show(target).hide(currentFragment);

            } else {
                fragmentTransaction.add(mContentId, target).show(target).hide(currentFragment);
            }
            fragmentTransaction.commit();
            currentTab = i;

            if (mFragmentToogleListener != null) {
                mFragmentToogleListener.onToogleChange(target, currentTab);
            }

        }
    }

}
 
Example #28
Source File: FeedbackActivity.java    From zhizhihu with Apache License 2.0 5 votes vote down vote up
@NonNull
private FrameLayout createRadioGroupLayout(final String[] typeList, RadioGroup.OnCheckedChangeListener listener) {
    final List<RadioButton> rbList = new ArrayList<>();
    final RadioGroup radioGroup = new RadioGroup(this);
    radioGroup.setPadding(24, 24, 24, 24);
    for (int i = 0; i < typeList.length; i++) {
        RadioButton rb = new RadioButton(this);
        rb.setText(typeList[i]);
        rbList.add(rb);
        radioGroup.addView(rb);
    }
    String curType = mFeedbackTypeTxt.getText().toString();
    for (RadioButton btn : rbList) {
        if (btn.getText().toString().equals(curType)) {
            radioGroup.check(btn.getId());
        }
    }
    radioGroup.setOnCheckedChangeListener(listener);
    FrameLayout frameLayout = new FrameLayout(this);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    lp.leftMargin = DimenUtil.dip2px(this, 24);
    lp.rightMargin = lp.leftMargin;
    frameLayout.addView(radioGroup, lp);
    return frameLayout;
}
 
Example #29
Source File: MainActivity.java    From AndroidHeros with MIT License 5 votes vote down vote up
public void visibilityNotify(View view){
    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.visibility_radio_group);
    Notification.Builder builder = new Notification.Builder(this).
            setContentTitle("Notification for Visibility Test");
    switch (radioGroup.getCheckedRadioButtonId()){
        case R.id.radio_button_public:
            builder.setVisibility(Notification.VISIBILITY_PUBLIC);
            builder.setContentText("Public");
            builder.setSmallIcon(R.mipmap.ic_public);
            break;
        case R.id.radio_button_private:
            builder.setVisibility(Notification.VISIBILITY_PRIVATE);
            builder.setContentText("Private");
            builder.setSmallIcon(R.mipmap.ic_private);
            break;
        case R.id.radio_button_secret:
            builder.setVisibility(Notification.VISIBILITY_SECRET);
            builder.setContentText("Secret");
            builder.setSmallIcon(R.mipmap.ic_secret);
            break;
        default:
            break;
    }

    NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID_VISIBILITY, builder.build());
}
 
Example #30
Source File: DemoActivity.java    From MultiRowsRadioGroup with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);

    RadioGroup radioGroup1 = (RadioGroup) findViewById(R.id.radioGroup1);
    radioGroup1.setOnCheckedChangeListener(onCheckedChangeListener);

    RadioGroup radioGroup2 = (RadioGroup) findViewById(R.id.radioGroup2);
    radioGroup2.setOnCheckedChangeListener(onCheckedChangeListener);

    RadioGroup radioGroup3 = (RadioGroup) findViewById(R.id.radioGroup3);
    radioGroup3.setOnCheckedChangeListener(onCheckedChangeListener);

}