Java Code Examples for android.widget.RadioGroup#setOnCheckedChangeListener()

The following examples show how to use android.widget.RadioGroup#setOnCheckedChangeListener() . 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: GenericUiControls.java    From BluetoothHidEmu with Apache License 2.0 6 votes vote down vote up
/**
 * setupTabs()
 */
private void setupTabs() {
    mTabsRadioGroup = (RadioGroup) mControlsLayout.findViewById(R.id.NavRadioGroup);
    mGenericHidViewFlipper = (ViewFlipper) mControlsLayout.findViewById(R.id.MainViewFlipper);
    
    mTabsRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            
            switch (checkedId) {
            case R.id.TouchpadRadioButton:
                mGenericHidViewFlipper.setDisplayedChild(0);
                break;
            case R.id.NavKeysRadioButton:
                mGenericHidViewFlipper.setDisplayedChild(1);
                break;
            case R.id.MediaKeysRadioButton:
                mGenericHidViewFlipper.setDisplayedChild(2);
                break;
            }
            
        }
    });
}
 
Example 2
Source File: SearchActivity.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
private void setupViews() {

        mLoadingView = findViewById(R.id.loading_layout);
        mUsersAdapter = new UsersAdapter();
        mTopicsAdapter = new TopicsAdapter();
        mRadioGroup = (RadioGroup) findViewById(R.id.radio_group);

        mListView = (ListView) findViewById(android.R.id.list);
        mEmptyView = findViewById(android.R.id.empty);
        mListView.setEmptyView(mEmptyView);
        mListView.setAdapter(mTopicsAdapter);
        mListView.setOnItemClickListener(this);

        mUsersBtn = (RadioButton) findViewById(R.id.users_btn);
        mTopicsBtn = (RadioButton) findViewById(R.id.topics_btn);
        mRadioGroup.setOnCheckedChangeListener(this);
    }
 
Example 3
Source File: ScenesSample.java    From Transitions-Everywhere with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_scenes, container, false);

    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene);
    radioGroup.setOnCheckedChangeListener(this);
    mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root);

    // A Scene can be instantiated from a live view hierarchy.
    mScene1 = new Scene(mSceneRoot, mSceneRoot.findViewById(R.id.container));

    // You can also inflate a generate a Scene from a layout resource file.
    mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, getContext());

    // Another scene from a layout resource file.
    mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene3, getContext());

    // We create a custom TransitionManager for Scene 3, in which ChangeBounds, Fade and
    // ChangeImageTransform take place at the same time.
    mTransitionManagerForScene3 = TransitionInflater.from(getContext())
        .inflateTransitionManager(R.transition.scene3_transition_manager, mSceneRoot);

    return view;
}
 
Example 4
Source File: Location_Activity.java    From Android_Location_Demo with Apache License 2.0 6 votes vote down vote up
private void initView(){
	rgLocationMode = (RadioGroup) findViewById(R.id.rg_locationMode);
	
	etInterval = (EditText) findViewById(R.id.et_interval);
	etHttpTimeout = (EditText) findViewById(R.id.et_httpTimeout);
	
	cbOnceLocation = (CheckBox)findViewById(R.id.cb_onceLocation);
	cbGpsFirst = (CheckBox) findViewById(R.id.cb_gpsFirst);
	cbAddress = (CheckBox) findViewById(R.id.cb_needAddress);
	cbCacheAble = (CheckBox) findViewById(R.id.cb_cacheAble);
	cbOnceLastest = (CheckBox) findViewById(R.id.cb_onceLastest);
	cbSensorAble = (CheckBox)findViewById(R.id.cb_sensorAble);

	tvResult = (TextView) findViewById(R.id.tv_result);
	btLocation = (Button) findViewById(R.id.bt_location);
	
	rgLocationMode.setOnCheckedChangeListener(this);
	btLocation.setOnClickListener(this);
}
 
Example 5
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 6
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 7
Source File: CircleProgressBarActivity.java    From CircleProgressBar with Apache License 2.0 6 votes vote down vote up
private void initLoading() {
    vLoading = LayoutInflater.from(this).inflate(R.layout.include_circleprogressbar_loading,
            vgControl, false);
    RadioGroup rgProgressMode = vLoading.findViewById(R.id.cpb_rg_progress_mode);
    rgProgressMode.setOnCheckedChangeListener(this);
    SeekBar sbLoadingStartAngle = vLoading.findViewById(R.id.cpb_sb_loading_start_angle);
    sbLoadingStartAngle.setOnSeekBarChangeListener(this);
    SeekBar sbLoadingSweepAngle = vLoading.findViewById(R.id.cpb_sb_loading_sweep_angle);
    sbLoadingSweepAngle.setOnSeekBarChangeListener(this);
    SeekBar sbLoadingDuration = vLoading.findViewById(R.id.cpb_sb_loading_duration);
    sbLoadingDuration.setOnSeekBarChangeListener(this);
    RadioGroup rgRepeatMode = vLoading.findViewById(R.id.cpb_rg_repeat_mode);
    rgRepeatMode.setOnCheckedChangeListener(this);
    Switch stDrawOther = vLoading.findViewById(R.id.cpb_st_loading_draw_other);
    stDrawOther.setOnCheckedChangeListener(this);
}
 
Example 8
Source File: ThermalCameraFragment.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Update ActionBar
    setActionBarTitle(R.string.thermalcamera_tab_title);

    // UI
    mUartWaitingTextView = view.findViewById(R.id.uartWaitingTextView);
    RadioGroup colorModeRadioGroup = view.findViewById(R.id.colorModeRadioGroup);
    colorModeRadioGroup.check(mIsColorEnabled ? R.id.colorModeColorButton : R.id.colorModeMonochromeButton);
    colorModeRadioGroup.setOnCheckedChangeListener((radioGroup, i) -> {
        mIsColorEnabled = i == R.id.colorModeColorButton;
        mThermalScaleView.updateGradient();
    });

    RadioGroup magnificationRadioGroup = view.findViewById(R.id.magnificationRadioGroup);
    magnificationRadioGroup.check(mIsFilterEnabled ? R.id.magnificationFilteredButton : R.id.magnificationPixelatedButton);
    magnificationRadioGroup.setOnCheckedChangeListener((radioGroup, i) -> mIsFilterEnabled = i == R.id.magnificationFilteredButton);

    mCameraImageView = view.findViewById(R.id.cameraImageView);
    mLowerTempTextView = view.findViewById(R.id.lowerTempTextView);
    mUpperTempTextView = view.findViewById(R.id.upperTempTextView);
    mThermalScaleView = view.findViewById(R.id.thermalScaleView);
    mThermalScaleView.setThermalCameraFragment(this);

    // Setup
    Context context = getContext();
    if (context != null) {
        mUartDataManager = new UartDataManager(context, this, true);
        setupUart();
    }
}
 
Example 9
Source File: MainActivity.java    From weixin with Apache License 2.0 5 votes vote down vote up
private void initView() {
	ActionBar actionBar = this.getActionBar();
	actionBar.setDisplayShowHomeEnabled(false);
	actionBar.setDisplayShowTitleEnabled(true);
	setOverflowShowingAlways();

	mFragmentManager = getFragmentManager();
	mRg_tab = (RadioGroup) findViewById(R.id.cgt_rg_tab);
	mRg_tab.setOnCheckedChangeListener(this);
}
 
Example 10
Source File: FABActivity.java    From fab with Apache License 2.0 5 votes vote down vote up
private void initButtonTypeRadioGroup() {
	buttonTypeRadioGroup = (RadioGroup) findViewById(R.id.fab_activity_radiogroup_button_type);
	switch (actionButton.getType()) {
		case DEFAULT:
			buttonTypeRadioGroup.check(R.id.fab_activity_radiobutton_default);
			break;
		case MINI:
			buttonTypeRadioGroup.check(R.id.fab_activity_radiobutton_mini);
			break;
		case BIG:
               buttonTypeRadioGroup.check(R.id.fab_activity_radiobutton_big);
               break;
	}
	buttonTypeRadioGroup.setOnCheckedChangeListener(new ButtonTypeChangeListener());
}
 
Example 11
Source File: AboutActivity.java    From v9porn with MIT License 5 votes vote down vote up
private void showAppreciateDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.MyDialogTheme);
    builder.setTitle("赞赏作者");
    View view = View.inflate(this, R.layout.layout_appreciate_qrcode, null);
    final ImageView imageViewWebChat = view.findViewById(R.id.iv_appreciate_qr_code_web_chat);
    final ImageView imageViewAliPay = view.findViewById(R.id.iv_appreciate_qr_code_ali_pay);
    final RadioGroup radioGroup = view.findViewById(R.id.rg_pay);
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch (checkedId) {
                case R.id.rb_web_chat:
                    imageViewWebChat.setVisibility(View.VISIBLE);
                    imageViewAliPay.setVisibility(View.GONE);
                    break;
                case R.id.rb_ali_pay:
                    imageViewWebChat.setVisibility(View.GONE);
                    imageViewAliPay.setVisibility(View.VISIBLE);
                    break;
            }
        }
    });
    builder.setView(view);
    builder.setNegativeButton("算了,囊中羞涩", null);
    builder.setPositiveButton("保存至相册", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (radioGroup.getCheckedRadioButtonId() == R.id.rb_ali_pay) {
                saveToSystemGallery("zhi_fu_bao", R.drawable.alipay1547141972480);
            } else {
                saveToSystemGallery("wei_xin", R.drawable.mm_reward_qrcode_1547141812376);
            }
        }
    });
    builder.show();
}
 
Example 12
Source File: CircleProgressBarActivity.java    From CircleProgressBar with Apache License 2.0 5 votes vote down vote up
private void initBase() {
    vBase = LayoutInflater.from(this).inflate(R.layout.include_circleprogressbar_base, vgControl,
            false);
    rgGravity1 = vBase.findViewById(R.id.cpb_rg_gravity_1);
    rgGravity1.setOnCheckedChangeListener(this);
    rgGravity2 = vBase.findViewById(R.id.cpb_rg_gravity_2);
    rgGravity2.setOnCheckedChangeListener(this);
    rgGravity3 = vBase.findViewById(R.id.cpb_rg_gravity_3);
    rgGravity3.setOnCheckedChangeListener(this);
    SeekBar sbRadius = vBase.findViewById(R.id.cpb_sb_radius);
    sbRadius.setOnSeekBarChangeListener(this);
    RadioGroup rgScaleType = vBase.findViewById(R.id.cpb_rg_scale_type);
    rgScaleType.setOnCheckedChangeListener(this);
}
 
Example 13
Source File: SettingFragment.java    From ksyhttpcache_android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_setting, container, false);
    btn_clean = (Button)view.findViewById(R.id.btn_clean);
    radio_size = (RadioButton) view.findViewById(R.id.radio_size);
    radio_num = (RadioButton) view.findViewById(R.id.radio_num);
    radio_hw = (RadioButton) view.findViewById(R.id.radio_hw);
    radio_sw = (RadioButton) view.findViewById(R.id.radio_sw);
    group_cache = (RadioGroup) view.findViewById(R.id.group_cache);
    group_decode = (RadioGroup) view.findViewById(R.id.group_decode);

    group_cache.setOnCheckedChangeListener(this);
    group_decode.setOnCheckedChangeListener(this);

    settings = getActivity().getSharedPreferences("SETTINGS", Context.MODE_PRIVATE);
    editor = settings.edit();
    choosedecode = settings.getString("choose_decode","信息为空");
    choosecache = settings.getString("choose_cache","信息为空");
    Log.d("decodeaa",choosecache+"  "+choosedecode);

    initSetting(choosecache,choosedecode);

    btn_clean.setOnClickListener(this);

    return view ;
}
 
Example 14
Source File: SettingActivity.java    From CoolClock with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setting);
    RadioGroup rg_taking_clock = (RadioGroup) findViewById(R.id.rg_talking_clock);
    rb_halfhour = (RadioButton) findViewById(R.id.rb_halfhour);
    rb_hours = (RadioButton) findViewById(R.id.rb_hours);
    rb_noreport = (RadioButton) findViewById(R.id.rb_noreport);
    weel_startTime = (WheelView) findViewById(R.id.weel_start_time);
    weel_stopTime = (WheelView) findViewById(R.id.weel_stop_time);

    et_city = (EditText) findViewById(R.id.et_city);
    et_description = (EditText) findViewById(R.id.et_description);
    model = new SharePerferenceModel();
    model.read();

    CheckBox cb_tick = (CheckBox) findViewById(R.id.cb_tick);
    cb_tick.setChecked(model.isTickSound());
    cb_tick.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            model.setTickSound(b);
        }
    });
    CheckBox cb_trigger_screen = (CheckBox) findViewById(R.id.cb_trigger_screen);
    cb_trigger_screen.setChecked(model.isTriggerScreen());
    cb_trigger_screen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            model.setTriggerScreen(isChecked);
        }
    });

    Button btn_uninstall = (Button) findViewById(R.id.btn_uninstall);
    btn_uninstall.setOnClickListener(this);
    Button btn_about = (Button) findViewById(R.id.btn_about);
    btn_about.setOnClickListener(this);


    for (int i = 0; i < 48; i++) {
        int hours = i / 2;
        int minutes = i % 2 * 30;
        String timeString = String.format("%02d:%02d", hours, (minutes + 1));
        listTime[i] = timeString;
    }

    ArrayWheelAdapter<String> timeAdpater = new ArrayWheelAdapter<String>(this, listTime);
    weel_startTime.setViewAdapter(timeAdpater);
    ArrayWheelAdapter<String> durationAdapter = new ArrayWheelAdapter<String>(this, listTime);
    weel_stopTime.setViewAdapter(durationAdapter);
    initData();

    rg_taking_clock.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int index) {
            int checkID = radioGroup.getCheckedRadioButtonId();
            switch (checkID) {
                case R.id.rb_halfhour:
                    model.setTypeHourPower(Constants.TALKING_HALF_AN_HOUR);
                    break;
                case R.id.rb_hours:
                    model.setTypeHourPower(Constants.TALKING_HOURS);
                    break;
                case R.id.rb_noreport:
                    model.setTypeHourPower(Constants.TALKING_NO_REPORT);
                    break;

            }

        }
    });
}
 
Example 15
Source File: MainActivity.java    From journaldev with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
    radioGroup.clearCheck();

    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            RadioButton rb = (RadioButton) group.findViewById(checkedId);
            if (null != rb && checkedId > -1) {
                Toast.makeText(MainActivity.this, rb.getText(), Toast.LENGTH_SHORT).show();
            }

        }
    });





}
 
Example 16
Source File: FontPreferenceData.java    From Status with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(View v) {
    ScrollView scrollView = new ScrollView(getContext());

    RadioGroup group = new RadioGroup(getContext());
    int vPadding = DimenUtils.dpToPx(12);
    group.setPadding(0, vPadding, 0, vPadding);

    AppCompatRadioButton normalButton = (AppCompatRadioButton) LayoutInflater.from(getContext()).inflate(R.layout.item_dialog_radio_button, group, false);
    normalButton.setId(0);
    normalButton.setText(R.string.font_default);
    normalButton.setChecked(preference == null || preference.length() == 0);
    group.addView(normalButton);

    for (int i = 0; i < items.size(); i++) {
        String item = items.get(i);

        AppCompatRadioButton button = (AppCompatRadioButton) LayoutInflater.from(getContext()).inflate(R.layout.item_dialog_radio_button, group, false);
        button.setId(i + 1);
        button.setText(item.replace(".ttf", ""));
        button.setTag(item);
        try {
            button.setTypeface(Typeface.createFromAsset(getContext().getAssets(), item));
        } catch (Exception e) {
            continue;
        }
        button.setChecked(preference != null && preference.equals(item));
        group.addView(button);
    }

    group.setOnCheckedChangeListener((group1, checkedId) -> {
        for (int i = 0; i < group1.getChildCount(); i++) {
            RadioButton child = (RadioButton) group1.getChildAt(i);
            child.setChecked(child.getId() == checkedId);
            if (child.getId() == checkedId)
                selectedPreference = (String) child.getTag();
        }
    });

    scrollView.addView(group);

    new AlertDialog.Builder(getContext())
            .setTitle(getIdentifier().getTitle())
            .setView(scrollView)
            .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                FontPreferenceData.this.preference = selectedPreference;

                getIdentifier().setPreferenceValue(getContext(), selectedPreference);
                onPreferenceChange(selectedPreference);
                selectedPreference = null;
            })
            .setNegativeButton(android.R.string.cancel, (dialog, which) -> selectedPreference = null)
            .show();
}
 
Example 17
Source File: SettingFragment.java    From ClassSchedule with Apache License 2.0 4 votes vote down vote up
private void showThemeDialog() {
    ScrollView scrollView = new ScrollView(getActivity());
    RadioGroup radioGroup = new RadioGroup(getActivity());
    scrollView.addView(radioGroup);
    int margin = ScreenUtils.dp2px(16);
    radioGroup.setPadding(margin / 2, margin, margin, margin);

    for (int i = 0; i < themeColorArray.length; i++) {
        AppCompatRadioButton arb = new AppCompatRadioButton(getActivity());

        RadioGroup.LayoutParams params =
                new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT);

        arb.setLayoutParams(params);
        arb.setId(i);
        arb.setTextColor(getResources().getColor(themeColorArray[i]));
        arb.setText(themeNameArray[i]);
        arb.setTextSize(16);
        arb.setPadding(0, margin / 2, 0, margin / 2);
        radioGroup.addView(arb);
    }

    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            theme = checkedId;
        }
    });

    DialogHelper dialogHelper = new DialogHelper();
    dialogHelper.showCustomDialog(getActivity(), scrollView,
            getString(R.string.theme_preference), new DialogListener() {
                @Override
                public void onPositive(DialogInterface dialog, int which) {
                    super.onPositive(dialog, which);
                    dialog.dismiss();
                    String key = getString(R.string.app_preference_theme);
                    int oldTheme = Preferences.getInt(key, 0);

                    if (theme != oldTheme) {
                        Preferences.putInt(key, theme);
                        ActivityUtil.finishAll();
                        startActivity(new Intent(app.mContext, CourseActivity.class));
                    }
                }
            });
}
 
Example 18
Source File: ReencodingDialog.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
	Context context = getActivity();
	qualityForm = new SeekBarForm(false);
	qualityForm.setConfiguration(1, 100, 1, 1);
	qualityForm.setValueFormat(getString(R.string.text_quality_format));
	qualityForm.setCurrentValue(savedInstanceState != null ? savedInstanceState.getInt(EXTRA_QUALITY) : 100);
	reduceForm = new SeekBarForm(false);
	reduceForm.setConfiguration(1, 8, 1, 1);
	reduceForm.setValueFormat(getString(R.string.text_reduce_format));
	reduceForm.setCurrentValue(savedInstanceState != null ? savedInstanceState.getInt(EXTRA_REDUCE) : 1);
	int padding = getResources().getDimensionPixelSize(R.dimen.dialog_padding_view);
	View qualityView = qualityForm.inflate(context);
	qualityForm.getSeekBar().setSaveEnabled(false);
	qualityView.setPadding(qualityView.getPaddingLeft(), 0, qualityView.getPaddingRight(), padding / 2);
	View reduceView = reduceForm.inflate(context);
	reduceForm.getSeekBar().setSaveEnabled(false);
	reduceView.setPadding(reduceView.getPaddingLeft(), 0, reduceView.getPaddingRight(),
			reduceView.getPaddingBottom());
	radioGroup = new RadioGroup(context);
	radioGroup.setOrientation(RadioGroup.VERTICAL);
	radioGroup.setPadding(padding, padding, padding, padding / 2);
	radioGroup.setOnCheckedChangeListener(this);
	for (int i = 0; i < OPTIONS.length; i++) {
		RadioButton radioButton = new RadioButton(context);
		radioButton.setText(OPTIONS[i]);
		radioButton.setId(IDS[i]);
		radioGroup.addView(radioButton);
	}
	radioGroup.check(IDS[0]);
	LinearLayout linearLayout = new LinearLayout(context);
	linearLayout.setOrientation(LinearLayout.VERTICAL);
	FrameLayout qualityLayout = new FrameLayout(context);
	qualityLayout.setId(android.R.id.text1);
	qualityLayout.addView(qualityView);
	FrameLayout reduceLayout = new FrameLayout(context);
	reduceLayout.setId(android.R.id.text2);
	reduceLayout.addView(reduceView);
	linearLayout.addView(radioGroup, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	linearLayout.addView(qualityLayout, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	linearLayout.addView(reduceLayout, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	ScrollView scrollView = new ScrollView(context);
	scrollView.addView(linearLayout, ScrollView.LayoutParams.MATCH_PARENT,
			ScrollView.LayoutParams.WRAP_CONTENT);
	return new AlertDialog.Builder(context).setTitle(R.string.text_reencode_image)
			.setView(scrollView).setNegativeButton(android.R.string.cancel, null)
			.setPositiveButton(android.R.string.ok, this).create();
}
 
Example 19
Source File: MainActivity.java    From pager-layoutmanager with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Log.i("GCS", "onCreate");

    mRadioGroup = (RadioGroup) findViewById(R.id.orientation_type);
    mRadioGroup.setOnCheckedChangeListener(this);

    mPageTotal = (TextView) findViewById(R.id.page_total);
    mPageCurrent = (TextView) findViewById(R.id.page_current);

    mLayoutManager = new PagerGridLayoutManager(mRows, mColumns, PagerGridLayoutManager
            .HORIZONTAL);


    // 系统带的 RecyclerView,无需自定义
    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);

    // 水平分页布局管理器
    mLayoutManager.setPageListener(this);    // 设置页面变化监听器
    mRecyclerView.setLayoutManager(mLayoutManager);

    // 设置滚动辅助工具
    PagerGridSnapHelper pageSnapHelper = new PagerGridSnapHelper();
    pageSnapHelper.attachToRecyclerView(mRecyclerView);

    // 如果需要查看调试日志可以设置为true,一般情况忽略即可
    PagerConfig.setShowLog(true);

    // 使用原生的 Adapter 即可
    mAdapter = new MyAdapter();
    mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override public void onChanged() {
            super.onChanged();
            int count = mAdapter.getItemCount();

        }
    });
    mRecyclerView.setAdapter(mAdapter);
}
 
Example 20
Source File: MainActivity.java    From PreviewSeekBar with Apache License 2.0 4 votes vote down vote up
private void setupOptions() {
    // Enable or disable the previews
    SwitchCompat previewSwitch = findViewById(R.id.previewEnabledSwitch);
    previewSwitch.setOnCheckedChangeListener(
            (buttonView, isChecked) -> {
                previewTimeBar.setPreviewEnabled(isChecked);
                previewSeekBar.setPreviewEnabled(isChecked);
            }
    );

    // Enable or disable auto-hide mode of previews
    SwitchCompat previewAutoHideSwitch = findViewById(R.id.previewAutoHideSwitch);
    previewAutoHideSwitch.setOnCheckedChangeListener(
            (buttonView, isChecked) -> {
                exoPlayerManager.setResumeVideoOnPreviewStop(isChecked);
                previewTimeBar.setAutoHidePreview(isChecked);
                previewSeekBar.setAutoHidePreview(isChecked);
            }
    );

    // Change the animations
    RadioGroup animationRadioGroup = findViewById(R.id.previewAnimationRadioGroup);
    animationRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {
        if (checkedId == R.id.noAnimationRadioButton) {
            previewTimeBar.setPreviewAnimationEnabled(false);
            previewSeekBar.setPreviewAnimationEnabled(false);
        } else {
            previewTimeBar.setPreviewAnimationEnabled(true);
            previewSeekBar.setPreviewAnimationEnabled(true);
            if (checkedId == R.id.fadeAnimationRadioButton) {
                previewTimeBar.setPreviewAnimator(new PreviewFadeAnimator());
                previewSeekBar.setPreviewAnimator(new PreviewFadeAnimator());
            } else if (Build.VERSION.SDK_INT >= 21) {
                previewTimeBar.setPreviewAnimator(new PreviewMorphAnimator());
                previewSeekBar.setPreviewAnimator(new PreviewMorphAnimator());
            }
        }
    });

    // Toggle previews
    Button toggleButton = findViewById(R.id.previewToggleButton);
    toggleButton.setOnClickListener(v -> {
        if (previewTimeBar.isShowingPreview()) {
            previewTimeBar.hidePreview();
        } else {
            previewTimeBar.showPreview();
            exoPlayerManager.loadPreview(previewTimeBar.getProgress(),
                    previewTimeBar.getMax());
        }
        if (previewSeekBar.isShowingPreview()) {
            previewSeekBar.hidePreview();
        } else {
            previewSeekBar.showPreview();
        }
    });

    // Change colors
    Button changeColorsButton = findViewById(R.id.previewToggleColors);
    changeColorsButton.setOnClickListener(v -> {
        final int seekBarColor = previewSeekBar.getScrubberColor();
        final int timeBarColor = previewTimeBar.getScrubberColor();
        previewSeekBar.setPreviewThumbTint(timeBarColor);
        previewSeekBar.setProgressTint(timeBarColor);
        previewTimeBar.setPreviewThumbTint(seekBarColor);
        previewTimeBar.setPlayedColor(seekBarColor);
    });

}