在我的Android项目中,我使用类方法为所有视图设置字体类型,方法如下:
public void overrideFonts(final Context context, final View v ) {
try {
if (v instanceof ViewGroup) {
ViewGroup vg = (ViewGroup) v;
for (int i = 0; i < vg.getChildCount(); i++) {
View child = vg.getChildAt(i);
overrideFonts(context, child);
}
} else if (v instanceof TextView) {
((TextView) v).setTypeface(Typeface.createFromAsset(context.getAssets(),"font/aFont.ttf"));
}
} catch (Exception e) {
}
}
除非我改变设备的方向,否则我的片段工作正常。之后,这种方法甚至无法恢复到肖像的方向! 我试过saveInstanceState(我觉得这不是我的问题).... 那么问题是什么?!
这是我在其中使用此方法的片段类。
public class aboutUs extends Fragment {
MUF option;
RelativeLayout relativeLayout;
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
option = new MUF(getActivity(), getContext());
relativeLayout = (RelativeLayout) getActivity().findViewById(R.id.aboutus_fragment);
option.overrideFonts(getContext(), relativeLayout);
Toast.makeText(getActivity(), "onActivityCreated", Toast.LENGTH_SHORT).show();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_about_us, container, false);
return view;
}
}
答案 0 :(得分:0)
Err:1 http://your.repo.domain/repository JollyRoger InRelease
Could not resolve 'your.repo.domain'
Ign:2 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:3 http://dl.google.com/linux/chrome/deb stable Release
Hit:4 http://deb.playonlinux.com wheezy InRelease
Get:5 http://mirrordirector.archive.parrotsec.org/parrot parrot InRelease [14.6 kB]
Err:5 http://mirrordirector.archive.parrotsec.org/parrot parrot InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ED05F7B2EC3C9224
Reading package lists... Done
W: GPG error: http://mirrordirector.archive.parrotsec.org/parrot parrot InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ED05F7B2EC3C9224
E: The repository 'http://mirrordirector.archive.parrotsec.org/parrot parrot InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
从您的AndroidManifest.xml中删除<activity
android:name=".ui.activities.MainActivity"//Your fragment's activity
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait" />
和"orientation"
,如果已添加到您的片段的活动中,也可以从"screenSize"
和android:configChanges
删除