本文整理匯總了Java中android.widget.RadioGroup.setOrientation方法的典型用法代碼示例。如果您正苦於以下問題:Java RadioGroup.setOrientation方法的具體用法?Java RadioGroup.setOrientation怎麽用?Java RadioGroup.setOrientation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.RadioGroup
的用法示例。
在下文中一共展示了RadioGroup.setOrientation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildButtonGroup
import android.widget.RadioGroup; //導入方法依賴的package包/類
private void buildButtonGroup() {
navButtonGroup = new RadioGroup(getContext());
navButtonGroup.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
navButtonGroup.setOrientation(LinearLayout.HORIZONTAL);
navButtonGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton btn = (RadioButton) group.getChildAt(checkedId);
if (btn == null)
return;
// 遊標劃動
if (navCursor != null) {
ObjectAnimator moveAnim = ObjectAnimator.ofFloat(navCursor, "x", navCursor.getX(), btn.getX());
ValueAnimator resizeWidthAnim = ValueAnimator.ofInt(navCursor.getMeasuredWidth(), btn.getMeasuredWidth());
resizeWidthAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
navCursor.getLayoutParams().width = (Integer) animation.getAnimatedValue();
navCursor.requestLayout();
}
});
AnimatorSet set = new AnimatorSet();
set.playTogether(moveAnim, resizeWidthAnim);
set.setDuration(200);
set.start();
}
if (group.getChildAt(2) != null)
smoothScrollTo(
((checkedId > 1) ? btn.getLeft() : 0) - group.getChildAt(2).getLeft(), 0);
if (mOnCheckedChangeListener != null) {
mOnCheckedChangeListener.onCheckedChanged(group, checkedId);
}
}
});
navContainer.addView(navButtonGroup);
}