在活动,我有:
public class tabsmain extends Activity{
public static Context appContext;
public boolean lf_ch=false;
public void onCreate(Bundle savedInstanceState){
我想访问,并可能从一个片段里tabsmain改变lf_ch;
I would like to access and possibly change lf_ch from a fragment inside tabsmain;
public class tabquests extends Fragment{
public CheckBox lc;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)//onCreateView
{
lc.setChecked(//set it to lf_ch);
不过,我似乎无法访问lf_ch的价值。
However, I can't seem to access the value of lf_ch.
试试这个:
public View onCreateView(...){
tabsmain xxx = (tabsmain)getActivity();
lc.setChecked(xxx.lf_ch);
}