我有资源<string-array name="channel_names">
和ID
<string-array name="channel_id">
<item>UCWUi0SCvgAGNJyS3Jmfibow</item>
</string-array>
或者不能将自定义字体用于字符串数组? 在课堂上:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Typeface font = Typeface.createFromAsset(getResources().getAssets(), "fonts/Arvo-BoldItalic.ttf");
channelNames = getResources().getStringArray(R.array.channel_names);
I do not understand what to use? .setTypeface(channelNames,font);
resourse
<string-array name="channel_names">
<item>TEXT</item>
</string-array>
I use navigation Drawer:
I do not have the xml file for the navigation drawer I draw to code
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
layoutList = (FrameLayout) findViewById(R.id.fragment_container);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
decorView = getWindow().getDecorView();
fragmentVideo = (FragmentVideo) getFragmentManager()
.findFragmentById(R.id.video_fragment_container);
Typeface font = Typeface.createFromAsset(getResources().getAssets(), "fonts/Arvo-BoldItalic.ttf");
channelNames = getResources().getStringArray(R.array.channel_names);
.setTypeface(channelNames,font);
channelId = getResources().getStringArray(R.array.channel_id);
videoTypes = getResources().getStringArray(R.array.video_types);
checkYouTubeApi();
PrimaryDrawerItem[] primaryDrawerItems = new PrimaryDrawerItem[channelId.length];
for (int i = 0; i < channelId.length; i++) {
primaryDrawerItems[i] =
new PrimaryDrawerItem().withName(channelNames[i]).withIdentifier(i)
.withSelectable(false);
}
AccountHeader accountHeader = new AccountHeaderBuilder().withActivity(this)
.withHeaderBackground(R.drawable.header).build();
drawer = new DrawerBuilder(this).withActivity(ActivityHome.this)
.withAccountHeader(accountHeader).withDisplayBelowStatusBar(true)
.withToolbar(toolbar).withActionBarDrawerToggleAnimated(true)
.withSavedInstance(savedInstanceState).addDrawerItems(primaryDrawerItems)
.addStickyDrawerItems(new SecondaryDrawerItem().withName(getString(R.string.about))
.withIdentifier(channelId.length - 1).withSelectable(false))
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
selectedDrawerItem = position;
if (drawerItem != null) {
if (drawerItem.getIdentifier() >= 0 && selectedDrawerItem != -1) {
setToolbarAndSelectedDrawerItem(
channelNames[selectedDrawerItem - 1],
(selectedDrawerItem - 1));
Bundle bundle = new Bundle();
bundle.putString(Utils.TAG_VIDEO_TYPE,
videoTypes[selectedDrawerItem - 1]);
bundle.putString(Utils.TAG_CHANNEL_ID,
channelId[selectedDrawerItem - 1]);
fragment = new FragmentChannelVideo();
fragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, fragment).commit();
} else if (selectedDrawerItem == -1) {
Intent aboutIntent =
new Intent(getApplicationContext(), ActivityAbout.class);
startActivity(aboutIntent);
overridePendingTransition(R.anim.open_next, R.anim.close_main);
}
}
return false;
}
}).withSavedInstance(savedInstanceState).withShowDrawerOnFirstLaunch(true).build();
setToolbarAndSelectedDrawerItem(channelNames[0], 0);
Bundle bundle = new Bundle();
bundle.putString(Utils.TAG_VIDEO_TYPE, videoTypes[selectedDrawerItem]);
bundle.putString(Utils.TAG_CHANNEL_ID, channelId[selectedDrawerItem]);
fragment = new FragmentChannelVideo();
fragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment)
.commit();
getSupportFragmentManager()
.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
@Override
public void onBackStackChanged() {
Fragment f = getSupportFragmentManager()
.findFragmentById(R.id.fragment_container);
if (f != null) {
updateTitleAndDrawer(f);
}
}
});
if (savedInstanceState == null) {
drawer.setSelection(0, false);
}
}
我没有为我编写代码的导航抽屉的xml文件