use of android.widget.CheckBox in project cw-omnibus by commonsguy.
the class DatePickerDemoActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
CheckBox cb = (CheckBox) findViewById(R.id.showCalendar);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
cb.setOnCheckedChangeListener(this);
} else {
cb.setVisibility(View.GONE);
}
GregorianCalendar now = new GregorianCalendar();
picker = (DatePicker) findViewById(R.id.picker);
picker.init(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH), this);
}
use of android.widget.CheckBox in project FloatingStickies by MohammadAdib.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
boolean key = prefs.getBoolean("key", false);
if (!key) {
setContentView(R.layout.tutorial);
final ImageView iv1 = (ImageView) findViewById(R.id.imageView1);
final ImageView iv2 = (ImageView) findViewById(R.id.imageView2);
final ImageView iv3 = (ImageView) findViewById(R.id.imageView3);
final ImageView iv4 = (ImageView) findViewById(R.id.done);
final CheckBox cb = (CheckBox) findViewById(R.id.checkBox);
final Animation anim1 = AnimationUtils.loadAnimation(this, R.anim.show);
final Animation anim2 = AnimationUtils.loadAnimation(this, R.anim.show);
final Animation anim3 = AnimationUtils.loadAnimation(this, R.anim.show);
final Animation anim4 = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
final Animation anim5 = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
final Animation anim6 = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
anim1.setDuration(500);
anim2.setDuration(500);
anim3.setDuration(500);
anim1.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
iv1.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
iv2.startAnimation(anim2);
}
});
anim2.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
iv2.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
iv3.startAnimation(anim3);
}
});
anim3.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
iv3.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
iv4.startAnimation(anim4);
iv4.setOnTouchListener(MainActivity.this);
}
});
anim4.setDuration(1000);
anim4.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
iv4.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
iv4.startAnimation(anim5);
}
});
anim5.setDuration(1000);
anim5.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
iv4.startAnimation(anim4);
}
});
iv1.startAnimation(anim1);
cb.startAnimation(anim6);
} else {
finish();
}
}
use of android.widget.CheckBox in project material-dialogs by afollestad.
the class MaterialDialog method onItemSelected.
@Override
public boolean onItemSelected(MaterialDialog dialog, View view, int position, CharSequence text, boolean longPress) {
if (!view.isEnabled()) {
return false;
}
if (listType == null || listType == ListType.REGULAR) {
// Default adapter, non choice mode
if (builder.autoDismiss) {
// If auto dismiss is enabled, dismiss the dialog when a list item is selected
dismiss();
}
if (!longPress && builder.listCallback != null) {
builder.listCallback.onSelection(this, view, position, builder.items.get(position));
}
if (longPress && builder.listLongCallback != null) {
return builder.listLongCallback.onLongSelection(this, view, position, builder.items.get(position));
}
} else {
// Default adapter, choice mode
if (listType == ListType.MULTI) {
final CheckBox cb = (CheckBox) view.findViewById(R.id.md_control);
if (!cb.isEnabled()) {
return false;
}
final boolean shouldBeChecked = !selectedIndicesList.contains(position);
if (shouldBeChecked) {
// Add the selection to the states first so the callback includes it (when alwaysCallMultiChoiceCallback)
selectedIndicesList.add(position);
if (builder.alwaysCallMultiChoiceCallback) {
// If the checkbox wasn't previously selected, and the callback returns true, add it to the states and check it
if (sendMultiChoiceCallback()) {
cb.setChecked(true);
} else {
// The callback cancelled selection, remove it from the states
selectedIndicesList.remove(Integer.valueOf(position));
}
} else {
// The callback was not used to check if selection is allowed, just select it
cb.setChecked(true);
}
} else {
// Remove the selection from the states first so the callback does not include it (when alwaysCallMultiChoiceCallback)
selectedIndicesList.remove(Integer.valueOf(position));
if (builder.alwaysCallMultiChoiceCallback) {
// If the checkbox was previously selected, and the callback returns true, remove it from the states and uncheck it
if (sendMultiChoiceCallback()) {
cb.setChecked(false);
} else {
// The callback cancelled unselection, re-add it to the states
selectedIndicesList.add(position);
}
} else {
// The callback was not used to check if the unselection is allowed, just uncheck it
cb.setChecked(false);
}
}
} else if (listType == ListType.SINGLE) {
final RadioButton radio = (RadioButton) view.findViewById(R.id.md_control);
if (!radio.isEnabled()) {
return false;
}
boolean allowSelection = true;
final int oldSelected = builder.selectedIndex;
if (builder.autoDismiss && builder.positiveText == null) {
// If auto dismiss is enabled, and no action button is visible to approve the selection, dismiss the dialog
dismiss();
// Don't allow the selection to be updated since the dialog is being dismissed anyways
allowSelection = false;
// Update selected index and send callback
builder.selectedIndex = position;
sendSingleChoiceCallback(view);
} else if (builder.alwaysCallSingleChoiceCallback) {
// Temporarily set the new index so the callback uses the right one
builder.selectedIndex = position;
// Only allow the radio button to be checked if the callback returns true
allowSelection = sendSingleChoiceCallback(view);
// Restore the old selected index, so the state is updated below
builder.selectedIndex = oldSelected;
}
// Update the checked states
if (allowSelection) {
builder.selectedIndex = position;
radio.setChecked(true);
builder.adapter.notifyItemChanged(oldSelected);
builder.adapter.notifyItemChanged(position);
}
}
}
return true;
}
use of android.widget.CheckBox in project android_frameworks_base by ParanoidAndroid.
the class UsbResolverActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
if (!(targetParcelable instanceof Intent)) {
Log.w("UsbResolverActivity", "Target is not an intent: " + targetParcelable);
finish();
return;
}
Intent target = (Intent) targetParcelable;
ArrayList<ResolveInfo> rList = intent.getParcelableArrayListExtra(EXTRA_RESOLVE_INFOS);
CharSequence title = getResources().getText(com.android.internal.R.string.chooseUsbActivity);
super.onCreate(savedInstanceState, target, title, null, rList, true);
CheckBox alwaysUse = (CheckBox) findViewById(com.android.internal.R.id.alwaysUse);
if (alwaysUse != null) {
if (mDevice == null) {
alwaysUse.setText(R.string.always_use_accessory);
} else {
alwaysUse.setText(R.string.always_use_device);
}
}
mDevice = (UsbDevice) target.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (mDevice != null) {
mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mDevice);
} else {
mAccessory = (UsbAccessory) target.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
if (mAccessory == null) {
Log.e(TAG, "no device or accessory");
finish();
return;
}
mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mAccessory);
}
}
use of android.widget.CheckBox in project android_frameworks_base by ParanoidAndroid.
the class ClientTest method onCreate.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button addpbtn = (Button) findViewById(R.id.addpkg);
Button procbtn = (Button) findViewById(R.id.procmsg);
Button delbtn = (Button) findViewById(R.id.delpkg);
Log.v(LOG_TAG, "activity created!!");
addpbtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText app_id = (EditText) findViewById(R.id.app_id);
EditText cont = (EditText) findViewById(R.id.cont);
EditText pkg = (EditText) findViewById(R.id.pkg);
EditText cls = (EditText) findViewById(R.id.cls);
RadioButton act = (RadioButton) findViewById(R.id.act);
CheckBox sig = (CheckBox) findViewById(R.id.sig);
CheckBox ftr = (CheckBox) findViewById(R.id.ftr);
try {
if (!mWapPushMan.addPackage(app_id.getText().toString(), cont.getText().toString(), pkg.getText().toString(), cls.getText().toString(), act.isChecked() ? WapPushManagerParams.APP_TYPE_ACTIVITY : WapPushManagerParams.APP_TYPE_SERVICE, sig.isChecked(), ftr.isChecked())) {
Log.w(LOG_TAG, "remote add pkg failed...");
mWapPushMan.updatePackage(app_id.getText().toString(), cont.getText().toString(), pkg.getText().toString(), cls.getText().toString(), act.isChecked() ? WapPushManagerParams.APP_TYPE_ACTIVITY : WapPushManagerParams.APP_TYPE_SERVICE, sig.isChecked(), ftr.isChecked());
}
} catch (RemoteException e) {
Log.w(LOG_TAG, "remote func failed...");
}
}
});
delbtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText app_id = (EditText) findViewById(R.id.app_id);
EditText cont = (EditText) findViewById(R.id.cont);
EditText pkg = (EditText) findViewById(R.id.pkg);
EditText cls = (EditText) findViewById(R.id.cls);
try {
mWapPushMan.deletePackage(app_id.getText().toString(), cont.getText().toString(), pkg.getText().toString(), cls.getText().toString());
// delall.isChecked());
} catch (RemoteException e) {
Log.w(LOG_TAG, "remote func failed...");
}
}
});
procbtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText pdu = (EditText) findViewById(R.id.pdu);
EditText app_id = (EditText) findViewById(R.id.app_id);
EditText cont = (EditText) findViewById(R.id.cont);
// wap.dispatchWapPdu(strToHex(pdu.getText().toString()));
try {
Intent intent = new Intent();
intent.putExtra("transactionId", 0);
intent.putExtra("pduType", 6);
intent.putExtra("header", HexDump.hexStringToByteArray(pdu.getText().toString()));
intent.putExtra("data", HexDump.hexStringToByteArray(pdu.getText().toString()));
mWapPushMan.processMessage(app_id.getText().toString(), cont.getText().toString(), intent);
//HexDump.hexStringToByteArray(pdu.getText().toString()), 0, 6, 5, 5);
} catch (RemoteException e) {
Log.w(LOG_TAG, "remote func failed...");
}
}
});
}
Aggregations