我是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(); –