android 改变系统字体 界面切换问题
主界面使用FragmentManager,FragmentTransaction和底部RadioGroup来控制界面切换,在app后台运行状态下,改变系统字体,这时再点击...
主界面使用FragmentManager,FragmentTransaction和底部RadioGroup来控制界面切换,在app后台运行状态下,改变系统字体,这时再点击底部按钮,fragment不切换,这是为啥,怎么处理?
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
fragmentTransaction = fragmentManager.beginTransaction();
switch (checkedId){
case R.id.btn_share_main:
hideFragment(fragmentTransaction);
if (shareFragment != null) {
fragmentTransaction.show(shareFragment);
}else{
shareFragment = new ShareFragment();
fragmentTransaction.add(R.id.main_container, shareFragment);
}
break;
case R.id.btn_school_main:
hideFragment(fragmentTransaction);
if (schoolFragment != null) {
fragmentTransaction.show(schoolFragment);
}else{
schoolFragment = new SchoolFragment();
fragmentTransaction.add(R.id.main_container, schoolFragment);
}
break;
case R.id.btn_personal_main:
hideFragment(fragmentTransaction);
if (personalFragment != null) {
fragmentTransaction.show(personalFragment);
}else{
personalFragment = new PersonalFragment();
fragmentTransaction.add(R.id.main_container, personalFragment);
}
break;
}
fragmentTransaction.commit();
} 展开
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
fragmentTransaction = fragmentManager.beginTransaction();
switch (checkedId){
case R.id.btn_share_main:
hideFragment(fragmentTransaction);
if (shareFragment != null) {
fragmentTransaction.show(shareFragment);
}else{
shareFragment = new ShareFragment();
fragmentTransaction.add(R.id.main_container, shareFragment);
}
break;
case R.id.btn_school_main:
hideFragment(fragmentTransaction);
if (schoolFragment != null) {
fragmentTransaction.show(schoolFragment);
}else{
schoolFragment = new SchoolFragment();
fragmentTransaction.add(R.id.main_container, schoolFragment);
}
break;
case R.id.btn_personal_main:
hideFragment(fragmentTransaction);
if (personalFragment != null) {
fragmentTransaction.show(personalFragment);
}else{
personalFragment = new PersonalFragment();
fragmentTransaction.add(R.id.main_container, personalFragment);
}
break;
}
fragmentTransaction.commit();
} 展开
展开全部
1.无参数Activity跳转
Intent it = new Intent(Activity.Main.this, Activity2.class);
startActivity(it);
2.向下一个Activity传递数据(使用Bundle和Intent.putExtras)
Intent it = new Intent(Activity.Main.this, Activity2.class);
Bundle bundle=new Bundle();
bundle.putString("name", "This is from MainActivity!");
it.putExtras(bundle); // it.putExtra(“test”, "shuju”);
startActivity(it); // startActivityForResult(it,REQUEST_CODE);
对于数据的获取可以采用:
Bundle bundle=getIntent().getExtras();
String name=bundle.getString("name");
3.向上一个Activity返回结果(使用setResult,针对startActivityForResult(it,REQUEST_CODE)启动的Activity)
Intent intent=getIntent();
Bundle bundle2=new Bundle();
bundle2.putString("name", "This is from ShowMsg!");
intent.putExtras(bundle2);
setResult(RESULT_OK, intent);
4.回调上一个Activity的结果处理函数(onActivityResult)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode==REQUEST_CODE){
if(resultCode==RESULT_CANCELED)
setTitle("cancle");
else if (resultCode==RESULT_OK) {
String temp=null;
Bundle bundle=data.getExtras();
if(bundle!=null) temp=bundle.getString("name");
setTitle(temp);
}
}
}
Intent it = new Intent(Activity.Main.this, Activity2.class);
startActivity(it);
2.向下一个Activity传递数据(使用Bundle和Intent.putExtras)
Intent it = new Intent(Activity.Main.this, Activity2.class);
Bundle bundle=new Bundle();
bundle.putString("name", "This is from MainActivity!");
it.putExtras(bundle); // it.putExtra(“test”, "shuju”);
startActivity(it); // startActivityForResult(it,REQUEST_CODE);
对于数据的获取可以采用:
Bundle bundle=getIntent().getExtras();
String name=bundle.getString("name");
3.向上一个Activity返回结果(使用setResult,针对startActivityForResult(it,REQUEST_CODE)启动的Activity)
Intent intent=getIntent();
Bundle bundle2=new Bundle();
bundle2.putString("name", "This is from ShowMsg!");
intent.putExtras(bundle2);
setResult(RESULT_OK, intent);
4.回调上一个Activity的结果处理函数(onActivityResult)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode==REQUEST_CODE){
if(resultCode==RESULT_CANCELED)
setTitle("cancle");
else if (resultCode==RESULT_OK) {
String temp=null;
Bundle bundle=data.getExtras();
if(bundle!=null) temp=bundle.getString("name");
setTitle(temp);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |