本文整理汇总了Java中android.widget.RadioButton.getId方法的典型用法代码示例。如果您正苦于以下问题:Java RadioButton.getId方法的具体用法?Java RadioButton.getId怎么用?Java RadioButton.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RadioButton
的用法示例。
在下文中一共展示了RadioButton.getId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: riskButtonListener
import android.widget.RadioButton; //导入方法依赖的package包/类
public void riskButtonListener(View v) {
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radio_group);
RadioButton radioButton = (RadioButton) findViewById(R.id.radio_yes);
TextView message = (TextView) findViewById(R.id.risk_validation);
if (radioGroup.getCheckedRadioButtonId() != -1) {
message.setVisibility(View.INVISIBLE);
mRisk = radioGroup.getCheckedRadioButtonId()
== radioButton.getId();
nextPage();
} else {
message.setVisibility(View.VISIBLE);
}
}
示例2: setCheckedId
import android.widget.RadioButton; //导入方法依赖的package包/类
/** 查找复合控件并设置id */
private void setCheckedId(ViewGroup vg) {
int len = vg.getChildCount();
for (int i = 0; i < len; i++) {
if (vg.getChildAt(i) instanceof RadioButton) {// 如果找到了,就设置check状态
final RadioButton button = (RadioButton) vg.getChildAt(i);
int id = button.getId();
// generates an id if it's missing
if (id == View.NO_ID) {
id = button.hashCode();
button.setId(id);
}
button.setOnCheckedChangeListener(mChildOnCheckedChangeListener);
} else if (vg.getChildAt(i) instanceof ViewGroup) {// 迭代查找并设置
ViewGroup childVg = (ViewGroup) vg.getChildAt(i);
setCheckedId(childVg);
}
}
}
示例3: onChildViewAdded
import android.widget.RadioButton; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void onChildViewAdded(View parent, View child) {
if (parent == MultiRadioGroup.this ) {
List<RadioButton> btns = getAllRadioButton(child);
if(btns != null && btns.size() > 0){
for(RadioButton btn : btns){
int id = btn.getId();
// generates an id if it's missing
if (id == View.NO_ID && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
id = View.generateViewId();
btn.setId(id);
}
btn.setOnCheckedChangeListener(
mChildOnCheckedChangeListener);
}
}
}
if (mOnHierarchyChangeListener != null) {
mOnHierarchyChangeListener.onChildViewAdded(parent, child);
}
}
示例4: onRadioButtonClicked
import android.widget.RadioButton; //导入方法依赖的package包/类
@OnClick({ R.id.rd_home, R.id.rd_features,R.id.rd_me }) public void onRadioButtonClicked(RadioButton radioButton) {
boolean checked = radioButton.isChecked();
switch (radioButton.getId()) {
case R.id.rd_home:
if (checked) {
fUtil.show(mFragments.get(0));break;
}
case R.id.rd_features:
if (checked) {
fUtil.show(mFragments.get(1));break;
}
case R.id.rd_me:
if (checked) {
fUtil.show(mFragments.get(2));break;
}
}
}
示例5: onSourceAlignmentChanged
import android.widget.RadioButton; //导入方法依赖的package包/类
@OnCheckedChanged({ R.id.source_align_start, R.id.source_align_center, R.id.source_align_end })
void onSourceAlignmentChanged(RadioButton button, boolean isChecked) {
if (isChecked) {
int alignment = Gravity.NO_GRAVITY;
switch (button.getId()) {
case R.id.source_align_start:
alignment = Gravity.START;
break;
case R.id.source_align_center:
alignment = Gravity.CENTER_HORIZONTAL;
break;
case R.id.source_align_end:
alignment = Gravity.END;
break;
}
onUpdateListener.updateSourceTextAlignment(alignment);
}
}
示例6: onTargetAlignmentChanged
import android.widget.RadioButton; //导入方法依赖的package包/类
@OnCheckedChanged({ R.id.target_align_start, R.id.target_align_center, R.id.target_align_end })
void onTargetAlignmentChanged(RadioButton button, boolean isChecked) {
if (isChecked) {
int alignment = Gravity.NO_GRAVITY;
switch (button.getId()) {
case R.id.target_align_start:
alignment = Gravity.START;
break;
case R.id.target_align_center:
alignment = Gravity.CENTER_HORIZONTAL;
break;
case R.id.target_align_end:
alignment = Gravity.END;
break;
}
onUpdateListener.updateTargetTextAlignment(alignment);
}
}
示例7: onRadioButtonClicked
import android.widget.RadioButton; //导入方法依赖的package包/类
/**
* onClick handler for radio buttons.
*/
public void onRadioButtonClicked(View view) {
int newSize;
RadioButton rb = (RadioButton) view;
if (!rb.isChecked()) {
Log.d(TAG, "Got click on non-checked radio button");
return;
}
switch (rb.getId()) {
case R.id.surfaceSizeTiny_radio:
newSize = SURFACE_SIZE_TINY;
break;
case R.id.surfaceSizeSmall_radio:
newSize = SURFACE_SIZE_SMALL;
break;
case R.id.surfaceSizeMedium_radio:
newSize = SURFACE_SIZE_MEDIUM;
break;
case R.id.surfaceSizeFull_radio:
newSize = SURFACE_SIZE_FULL;
break;
default:
throw new RuntimeException("Click from unknown id " + rb.getId());
}
mSelectedSize = newSize;
int[] wh = mWindowWidthHeight[newSize];
// Update the Surface size. This causes a "surface changed" event, but does not
// destroy and re-create the Surface.
SurfaceView sv = (SurfaceView) findViewById(R.id.hardwareScaler_surfaceView);
SurfaceHolder sh = sv.getHolder();
Log.d(TAG, "setting size to " + wh[0] + "x" + wh[1]);
sh.setFixedSize(wh[0], wh[1]);
}
示例8: onRadioButtonClicked
import android.widget.RadioButton; //导入方法依赖的package包/类
/**
* onClick handler for radio buttons.
*/
public void onRadioButtonClicked(View view) {
RadioButton rb = (RadioButton) view;
if (!rb.isChecked()) {
Log.d(TAG, "Got click on non-checked radio button");
return;
}
switch (rb.getId()) {
case R.id.recDrawTwice_radio:
mSelectedRecordMethod = RECMETHOD_DRAW_TWICE;
break;
case R.id.recFbo_radio:
mSelectedRecordMethod = RECMETHOD_FBO;
break;
case R.id.recFramebuffer_radio:
mSelectedRecordMethod = RECMETHOD_BLIT_FRAMEBUFFER;
break;
default:
throw new RuntimeException("Click from unknown id " + rb.getId());
}
Log.d(TAG, "Selected rec mode " + mSelectedRecordMethod);
RenderHandler rh = mRenderThread.getHandler();
if (rh != null) {
rh.setRecordMethod(mSelectedRecordMethod);
}
}
示例9: onClick
import android.widget.RadioButton; //导入方法依赖的package包/类
public void onClick(View v) {
RadioButton rb = (RadioButton) v;
if (rb.getId() == R.id.rbclassic) {
prefs.notationstyle = "classic";
prefs.SavePreferences();
}
else if (rb.getId() == R.id.rbletters) {
prefs.notationstyle = "letters";
prefs.SavePreferences();
}
}