use of android.widget.CheckBox in project android_frameworks_base by ParanoidAndroid.
the class TransformsAndAnimationsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.transforms_and_animations);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button1a = (Button) findViewById(R.id.button1a);
button2a = (Button) findViewById(R.id.button2a);
button3a = (Button) findViewById(R.id.button3a);
button1b = (Button) findViewById(R.id.button1b);
button2b = (Button) findViewById(R.id.button2b);
button3b = (Button) findViewById(R.id.button3b);
button4 = (Button) findViewById(R.id.button4);
button5 = (Button) findViewById(R.id.button5);
button6 = (Button) findViewById(R.id.button6);
button7 = (Button) findViewById(R.id.button7);
button8 = (Button) findViewById(R.id.button8);
layersNoneCB = (CheckBox) findViewById(R.id.layersNoneCB);
layersHardwareCB = (CheckBox) findViewById(R.id.layersHwCB);
layersSoftwareCB = (CheckBox) findViewById(R.id.layersSwCB);
layersNoneCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_NONE);
layersHardwareCB.setChecked(false);
layersSoftwareCB.setChecked(false);
}
}
});
layersSoftwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_SOFTWARE);
layersHardwareCB.setChecked(false);
layersNoneCB.setChecked(false);
}
}
});
layersHardwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_HARDWARE);
layersNoneCB.setChecked(false);
layersSoftwareCB.setChecked(false);
}
}
});
button1a.setAlpha(.5f);
button2a.setAlpha(.5f);
button3a.setAlpha(.5f);
button3.setTranslationX(50);
button7.setTranslationX(50);
button8.setTranslationX(50);
final AlphaAnimation alphaAnim = new AlphaAnimation(1, 0);
alphaAnim.setDuration(1000);
alphaAnim.setRepeatCount(Animation.INFINITE);
alphaAnim.setRepeatMode(Animation.REVERSE);
final TranslateAnimation transAnim = new TranslateAnimation(0, -50, 0, 0);
transAnim.setDuration(1000);
transAnim.setRepeatCount(Animation.INFINITE);
transAnim.setRepeatMode(Animation.REVERSE);
getWindow().getDecorView().postDelayed(new Runnable() {
@Override
public void run() {
button1.startAnimation(alphaAnim);
button2.startAnimation(alphaAnim);
button3.startAnimation(alphaAnim);
button1a.startAnimation(alphaAnim);
button2a.startAnimation(alphaAnim);
button3a.startAnimation(alphaAnim);
button1b.startAnimation(alphaAnim);
button2b.startAnimation(alphaAnim);
button3b.startAnimation(alphaAnim);
startAnimator(button1b);
startAnimator(button2b);
startAnimator(button3b);
button7.startAnimation(transAnim);
button8.startAnimation(transAnim);
}
}, 2000);
}
use of android.widget.CheckBox in project tree-view-list-android by Polidea.
the class SimpleStandardAdapter method handleItemClick.
@Override
public void handleItemClick(final View view, final Object id) {
final Long longId = (Long) id;
final TreeNodeInfo<Long> info = getManager().getNodeInfo(longId);
if (info.isWithChildren()) {
super.handleItemClick(view, id);
} else {
final ViewGroup vg = (ViewGroup) view;
final CheckBox cb = (CheckBox) vg.findViewById(R.id.demo_list_checkbox);
cb.performClick();
}
}
use of android.widget.CheckBox in project RoboBinding by RoboBinding.
the class AbstractCompoundButtonAttributeTest method initializeViewAndListeners.
@Before
public void initializeViewAndListeners() {
view = new CheckBox(RuntimeEnvironment.application);
viewAddOn = new MockCompoundButtonAddOn(view);
}
use of android.widget.CheckBox in project RoboBinding by RoboBinding.
the class CompoundButtonAddOnTest method shouldSupportMultipleOnCheckedChangeListeners.
@Test
public void shouldSupportMultipleOnCheckedChangeListeners() {
CheckBox view = new CheckBox(RuntimeEnvironment.application);
CompoundButtonAddOn viewAddOn = new CompoundButtonAddOn(view);
MockOnCheckedChangeListener listener1 = new MockOnCheckedChangeListener();
MockOnCheckedChangeListener listener2 = new MockOnCheckedChangeListener();
viewAddOn.addOnCheckedChangeListener(listener1);
viewAddOn.addOnCheckedChangeListener(listener2);
view.setChecked(!view.isChecked());
assertTrue(listener1.checkedChangeEventFired);
assertTrue(listener2.checkedChangeEventFired);
}
use of android.widget.CheckBox in project KeepScore by nolanlawson.
the class SavedGameAdapter method getView.
@Override
public View getView(int position, View view, ViewGroup parent) {
// view wrapper optimization per Romain Guy
final Context context = parent.getContext();
ViewWrapper viewWrapper;
if (view == null) {
LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = vi.inflate(R.layout.saved_game_item, parent, false);
viewWrapper = new ViewWrapper(view);
view.setTag(viewWrapper);
} else {
viewWrapper = (ViewWrapper) view.getTag();
}
TextView titleTextView = viewWrapper.getTitleTextView();
TextView numPlayersTextView = viewWrapper.getNumPlayersTextView();
TextView subtitleTextView = viewWrapper.getSubtitleTextView();
TextView savedTextView = viewWrapper.getSavedTextView();
CheckBox checkBox = viewWrapper.getCheckBox();
final GameSummary game = getItem(position);
StringBuilder gameTitle = new StringBuilder();
if (!TextUtils.isEmpty(game.getName())) {
gameTitle.append(game.getName()).append(" ").append(context.getString(R.string.text_game_name_separator)).append(" ");
}
// Player 1, Player 2, Player3 etc.
gameTitle.append(TextUtils.join(", ", CollectionUtil.transformWithIndices(game.getPlayerNames(), new FunctionWithIndex<String, CharSequence>() {
@Override
public CharSequence apply(String playerName, int index) {
return PlayerScore.toDisplayName(playerName, index, context);
}
})));
titleTextView.setText(gameTitle);
numPlayersTextView.setText(Integer.toString(game.getPlayerNames().size()));
numPlayersTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimensionPixelSize(// two
game.getPlayerNames().size() >= 10 ? // digit
R.dimen.saved_game_num_players_text_size_two_digits : R.dimen.saved_game_num_players_text_size_one_digit));
int numRounds = game.getNumRounds();
int roundsResId = numRounds == 1 ? R.string.text_format_rounds_singular : R.string.text_format_rounds;
String rounds = String.format(context.getString(roundsResId), numRounds);
subtitleTextView.setText(rounds);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(getContext().getString(R.string.date_format), Locale.getDefault());
savedTextView.setText(simpleDateFormat.format(new Date(game.getDateSaved())));
checkBox.setOnCheckedChangeListener(null);
checkBox.setChecked(checked.contains(game));
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
checked.add(game);
} else {
checked.remove(game);
}
if (onCheckChangedRunnable != null) {
onCheckChangedRunnable.run();
}
}
});
log.d("saved long is: %s", game.getDateSaved());
return view;
}
Aggregations