I'm new in this world of Android and I'm learning making an app, so I got a problem.
Working on
I created a fragment and inside I have a radio group containing 3 radio buttons
Goal
Clear all the radio buttons inside the fragment when the user returns to this screen
Problem
I don't know how to achieve that
Question
How to clear all checks of the radio buttons?
Steps done
I tried the following:
But it seems I can't do it
Code
This piece of code doesn't work for me (from the post above)
protected void onResume()
{
RadioGroup rg=(RadioGroup)findViewById(R.id.RG);
rg.clearCheck();
super.onResume();
}
But I have the following:
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();
}
}
I'm interested in place the code inside onResume()
I know there is docs about fragments (https://developer.android.com/guide/components/fragments.html) but those can't answer my questions
Thanks in advance