我是Android这个世界的新手,我正在学习制作应用程序,所以我遇到了问题。Android - 如何取消选中片段内的广播组中的单选按钮?
上
工作我创建了一个片段和内部我有一个包含3个单选按钮
清除所有的单选按钮的片段内目标一个无线电组当用户返回到此屏幕时
问题
我不知道如何实现这一
问题
如何清除单选按钮的所有检查?
步骤完成
我试过如下:
但似乎我不能这样做
代码
这段代码不为我工作(从上面的文章)
protected void onResume()
{
RadioGroup rg=(RadioGroup)findViewById(R.id.RG);
rg.clearCheck();
super.onResume();
}
但我有以下几点:
public class Operations extends Fragment
{
RadioButton surfArea, rad, diam;
RadioGroup radG;
Button openSelect;
public Operations()
{
// Required empty public constructor
}
public static Operations newInstance()
{
return new Operations();
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.fragment_operations_sphere, container, false);
surfArea = (RadioButton) rootView.findViewById(R.id.RB_surfArea);
rad = (RadioButton) rootView.findViewById(R.id.RB_Rad);
diam = (RadioButton) rootView.findViewById(R.id.RB_Diam);
openSelect = (Button) rootView.findViewById(R.id.btn_open_select);
//This piece is for testing purposes
openSelect.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
if (surfArea.isChecked())
{
Intent sa = new Intent(getContext(), OperSphere.class);
startActivity(sa);
}
}
});
return rootView;
}
//Here is where I'm stuck
@Override
public void onResume()
{
super.onResume();
}
}
我感兴趣到位内onResume()
我知道有关于碎片的文档(https://developer.android.com/guide/components/fragments.html),但那些不能回答我的问题
在此先感谢
看起来更符合逻辑的我先调用super.onResume()让Android框架执行任何它所需的操作,然后运行您的代码。 –
你能详细说明吗? – NAYIR55
super.onResume(); RadioGroup rg =(RadioGroup)findViewById(R.id.RG); rg.clearCheck(); –