use of android.widget.CompoundButton in project EasyRecyclerView by Jude95.
the class RefreshAndMoreActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem item = menu.findItem(R.id.checkbox);
CheckBox box = (CheckBox) item.getActionView();
box.setChecked(true);
box.setText("网络");
box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
hasNetWork = isChecked;
}
});
return true;
}
use of android.widget.CompoundButton in project UltimateAndroid by cymcsg.
the class CropperSample method onCreate.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.cropper_activity);
// Sets fonts for all
Typeface mFont = Typeface.createFromAsset(getAssets(), "Roboto-Thin.ttf");
ViewGroup root = (ViewGroup) findViewById(R.id.mylayout);
setFont(root, mFont);
// Initialize components of the app
final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView);
final SeekBar aspectRatioXSeek = (SeekBar) findViewById(R.id.aspectRatioXSeek);
final SeekBar aspectRatioYSeek = (SeekBar) findViewById(R.id.aspectRatioYSeek);
final ToggleButton fixedAspectRatioToggle = (ToggleButton) findViewById(R.id.fixedAspectRatioToggle);
Spinner showGuidelinesSpin = (Spinner) findViewById(R.id.showGuidelinesSpin);
// Sets sliders to be disabled until fixedAspectRatio is set
aspectRatioXSeek.setEnabled(false);
aspectRatioYSeek.setEnabled(false);
// Set initial spinner value
showGuidelinesSpin.setSelection(ON_TOUCH);
//Sets the rotate button
final Button rotateButton = (Button) findViewById(R.id.Button_rotate);
rotateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cropImageView.rotateImage(ROTATE_NINETY_DEGREES);
}
});
// Sets fixedAspectRatio
fixedAspectRatioToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cropImageView.setFixedAspectRatio(isChecked);
if (isChecked) {
aspectRatioXSeek.setEnabled(true);
aspectRatioYSeek.setEnabled(true);
} else {
aspectRatioXSeek.setEnabled(false);
aspectRatioYSeek.setEnabled(false);
}
}
});
// Sets initial aspect ratio to 10/10, for demonstration purposes
cropImageView.setAspectRatio(DEFAULT_ASPECT_RATIO_VALUES, DEFAULT_ASPECT_RATIO_VALUES);
// Sets aspectRatioX
final TextView aspectRatioX = (TextView) findViewById(R.id.aspectRatioX);
aspectRatioXSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar aspectRatioXSeek, int progress, boolean fromUser) {
try {
mAspectRatioX = progress;
cropImageView.setAspectRatio(progress, mAspectRatioY);
aspectRatioX.setText(" " + progress);
} catch (IllegalArgumentException e) {
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// Sets aspectRatioY
final TextView aspectRatioY = (TextView) findViewById(R.id.aspectRatioY);
aspectRatioYSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar aspectRatioYSeek, int progress, boolean fromUser) {
try {
mAspectRatioY = progress;
cropImageView.setAspectRatio(mAspectRatioX, progress);
aspectRatioY.setText(" " + progress);
} catch (IllegalArgumentException e) {
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// Sets up the Spinner
showGuidelinesSpin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
cropImageView.setGuidelines(i);
}
public void onNothingSelected(AdapterView<?> adapterView) {
return;
}
});
final Button cropButton = (Button) findViewById(R.id.Button_crop);
cropButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
croppedImage = cropImageView.getCroppedImage();
ImageView croppedImageView = (ImageView) findViewById(R.id.croppedImageView);
croppedImageView.setImageBitmap(croppedImage);
}
});
}
use of android.widget.CompoundButton in project BaseRecyclerViewAdapterHelper by CymChad.
the class AnimationUseActivity method initMenu.
private void initMenu() {
MaterialSpinner spinner = (MaterialSpinner) findViewById(R.id.spinner);
spinner.setItems("AlphaIn", "ScaleIn", "SlideInBottom", "SlideInLeft", "SlideInRight", "Custom");
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
@Override
public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
switch(position) {
case 0:
mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
break;
case 1:
mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
break;
case 2:
mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_BOTTOM);
break;
case 3:
mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_LEFT);
break;
case 4:
mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_RIGHT);
break;
case 5:
mAnimationAdapter.openLoadAnimation(new CustomAnimation());
break;
default:
break;
}
mRecyclerView.setAdapter(mAnimationAdapter);
}
});
SwitchButton switchButton = (SwitchButton) findViewById(R.id.switch_button);
switchButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
if (isChecked) {
mAnimationAdapter.isFirstOnly(true);
} else {
mAnimationAdapter.isFirstOnly(false);
}
mAnimationAdapter.notifyDataSetChanged();
}
});
}
use of android.widget.CompoundButton in project BaseRecyclerViewAdapterHelper by CymChad.
the class BaseViewHolder method setOnCheckedChangeListener.
/**
* Sets the on checked change listener of the view.
*
* @param viewId The view id.
* @param listener The checked change listener of compound button.
* @return The BaseViewHolder for chaining.
*/
public BaseViewHolder setOnCheckedChangeListener(int viewId, CompoundButton.OnCheckedChangeListener listener) {
CompoundButton view = getView(viewId);
view.setOnCheckedChangeListener(listener);
return this;
}
use of android.widget.CompoundButton in project android_packages_apps_Torch by CyanogenMod.
the class MainActivity method onCreate.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mButtonOn = (ToggleButton) findViewById(R.id.buttonOn);
mStrobeSwitch = (Switch) findViewById(R.id.strobe_switch);
mStrobeLabel = (TextView) findViewById(R.id.strobeTimeLabel);
mSlider = (SeekBar) findViewById(R.id.slider);
mBrightSwitch = (Switch) findViewById(R.id.bright_switch);
mStrobePeriod = 100;
mTorchOn = false;
mWidgetProvider = TorchWidgetProvider.getInstance();
// Preferences
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mHasBrightSetting = getResources().getBoolean(R.bool.hasHighBrightness);
if (mHasBrightSetting) {
mBright = mPrefs.getBoolean("bright", false);
mBrightSwitch.setChecked(mBright);
mBrightSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked && mPrefs.getBoolean("bright", false)) {
mBright = true;
} else if (isChecked) {
openBrightDialog();
} else {
mBright = false;
mPrefs.edit().putBoolean("bright", false).commit();
}
}
});
} else {
// Fully hide the UI elements on Crespo since we can't use them
mBrightSwitch.setVisibility(View.GONE);
findViewById(R.id.ruler2).setVisibility(View.GONE);
}
// Set the state of the strobing section and hide as appropriate
final boolean isStrobing = mPrefs.getBoolean("strobe", false);
final LinearLayout strobeLayout = (LinearLayout) findViewById(R.id.strobeRow);
int visibility = isStrobing ? View.VISIBLE : View.GONE;
strobeLayout.setVisibility(visibility);
mStrobeSwitch.setChecked(isStrobing);
mStrobeSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int visibility = isChecked ? View.VISIBLE : View.GONE;
strobeLayout.setVisibility(visibility);
mPrefs.edit().putBoolean("strobe", isChecked).commit();
}
});
mButtonOn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(TorchSwitch.TOGGLE_FLASHLIGHT);
intent.putExtra("strobe", mStrobeSwitch.isChecked());
intent.putExtra("period", mStrobePeriod);
intent.putExtra("bright", mBright);
sendBroadcast(intent);
}
});
// Strobe frequency slider bar handling
setProgressBarVisibility(true);
updateStrobePeriod(mPrefs.getInt("strobeperiod", 100));
mSlider.setHorizontalScrollBarEnabled(true);
mSlider.setProgress(400 - mStrobePeriod);
mSlider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
updateStrobePeriod(Math.max(20, 401 - progress));
Intent intent = new Intent("net.cactii.flash2.SET_STROBE");
intent.putExtra("period", mStrobePeriod);
sendBroadcast(intent);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// Show the about dialog, the first time the user runs the app.
if (!mPrefs.getBoolean("aboutSeen", false)) {
openAboutDialog();
mPrefs.edit().putBoolean("aboutSeen", true).commit();
}
}
Aggregations