本文整理匯總了Java中com.mikepenz.materialdrawer.DrawerBuilder類的典型用法代碼示例。如果您正苦於以下問題:Java DrawerBuilder類的具體用法?Java DrawerBuilder怎麽用?Java DrawerBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DrawerBuilder類屬於com.mikepenz.materialdrawer包,在下文中一共展示了DrawerBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initDrawer
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
@UiThread void initDrawer() {
PrimaryDrawerItem home =
new PrimaryDrawerItem().withName(R.string.home).withIcon(GoogleMaterial.Icon.gmd_home);
new DrawerBuilder().withActivity((Activity) act)
.withToolbar(toolbar)
.withHasStableIds(true)
.withTranslucentStatusBar(true)
.withSelectedItem(-1)
.withAccountHeader(headerResult)
.addDrawerItems(home)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
switch (position) {
case 1:
context.startActivity(new Intent(context, MainActivity_.class));
return true;
default:
return true;
}
}
})
.build();
}
示例2: onCreateView
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
// don't look at this layout it's just a listView to show how to handle the keyboard
View view = inflater.inflate(R.layout.fragment_simple_sample, container, false);
result = new DrawerBuilder()
.withActivity(getActivity())
.withRootView((ViewGroup) view.findViewById(R.id.rootView))
.withDisplayBelowStatusBar(false)
.withSavedInstance(savedInstanceState)
.addDrawerItems(
new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1),
new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye)
)
.buildForFragment();
TextView textView = (TextView) view.findViewById(R.id.title);
textView.setText(getArguments().getString(KEY_TITLE));
result.getDrawerLayout().setFitsSystemWindows(false);
result.getSlider().setFitsSystemWindows(false);
return view;
}
示例3: onCreate
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_dark_toolbar);
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.drawer_item_menu_drawer);
//Create the drawer
result = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.inflateMenu(R.menu.example_menu)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem instanceof Nameable) {
Toast.makeText(MenuDrawerActivity.this, ((Nameable) drawerItem).getName().getText(MenuDrawerActivity.this), Toast.LENGTH_SHORT).show();
}
return false;
}
}).build();
}
示例4: initializeDrawer
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
public void initializeDrawer(Activity activity) {
this.response = new DrawerBuilder().withActivity(activity)
.addDrawerItems(
audioActivity,
fileActivity,
new DividerDrawerItem(),
about
).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
updatedSelection();
return true;
}
})
.build();
}
示例5: DrawerHelper
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
@Inject
public DrawerHelper(final AppCompatActivity activity) {
View view = LayoutInflater.from(activity).inflate(R.layout.view_menu_header, null);
TextView textTitle = view.findViewById(R.id.menu_title);
FontsUtils.toOctarineBold(activity, textTitle);
drawer = new DrawerBuilder()
.withActivity(activity)
.withSliderBackgroundDrawableRes(R.drawable.fon_gradient)
.withHeader(R.layout.view_menu_header)
.withHeader(view)
.withActionBarDrawerToggle(true)
.withStickyFooter(R.layout.view_menu_footer)
.withStickyFooterDivider(false)
.build();
if (activity instanceof Drawer.OnDrawerItemClickListener) {
drawer.setOnDrawerItemClickListener((Drawer.OnDrawerItemClickListener) activity);
}
}
示例6: buildDrawer
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
/**
* Creates a new drawer for this application with predefined items
*
* @param activity
* @param toolbar
* @return
*/
public void buildDrawer(Activity activity, Toolbar toolbar) {
//@formatter:off
mDrawer = new DrawerBuilder()
.withActivity(activity)
.withToolbar(toolbar)
.withDrawerItems(getDrawerItems())
.withSelectedItemByPosition(getLastSelectedItemPosition())
.withAccountHeader(getAccountHeader(activity))
.addDrawerItems()
.build();
//@formatter:on
}
示例7: setUpDrawer
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
protected void setUpDrawer(Toolbar ssToolbar){
this.ssNavigationDrawer = new DrawerBuilder()
.withActivity(this)
.withToolbar(ssToolbar)
.withAccountHeader(getAccountHeader())
.addDrawerItems(getDrawerItems())
.withOnDrawerItemClickListener(this)
.withSelectedItem(1)
.build();
}
示例8: setDrawer
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
protected void setDrawer(Boolean upEnabled) {
Toolbar toolbar_main = (Toolbar) findViewById(R.id.toolbar_main);
setSupportActionBar(toolbar_main);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null)
if (upEnabled) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
} else {
final Intent intent = new Intent(this, FormActivity.class);
new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar_main)
.addDrawerItems(
new PrimaryDrawerItem()
.withName(R.string.new_task)
.withIcon(MaterialDesignIconic.Icon.gmi_plus)
.withSelectable(false)
.withIdentifier(1)
).withSelectedItem(-1)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
switch (drawerItem.getIdentifier()) {
case 1:
startActivityForResult(intent, NEW_TASK);
break;
}
return false;
}
})
.build();
}
}
示例9: setupNavigationDrawer
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
private void setupNavigationDrawer() {
ProfileDrawerItem section = new ProfileDrawerItem()
.withSetSelected(false)
.withSetSelected(false)
.withEnabled(false);
PrimaryDrawerItem joyType0DrawerItem = new PrimaryDrawerItem().withName("Basic Gamepad").withTag(KEY_BASIC_GAMEPAD_1).withLevel(2);
PrimaryDrawerItem joyType1DrawerItem = new PrimaryDrawerItem().withName("Assault Horizon").withTag(KEY_ASSAULT_HORIZON).withLevel(2);
PrimaryDrawerItem joyType2DrawerItem = new PrimaryDrawerItem().withName("Awesomenauts").withTag(KEY_AWESOMENAUTS).withLevel(2);
PrimaryDrawerItem joyType3DrawerItem = new PrimaryDrawerItem().withName("BombSquad").withTag(KEY_BOMBSQUAD).withLevel(2);
PrimaryDrawerItem joyType4DrawerItem = new PrimaryDrawerItem().withName("Final Fantasy XIII").withTag(KEY_FINAL_FANTASY_XIII).withLevel(2);
SectionDrawerItem sectionDrawerItem = new SectionDrawerItem().withName("Joystick Type").withTextColorRes(R.color.colorAccent);
PrimaryDrawerItem deviceDrawerItem = new PrimaryDrawerItem().withName("Device Connection").withTag(KEY_DEVICE_CONNECTION).withIcon(GoogleMaterial.Icon.gmd_devices);
PrimaryDrawerItem settingsDrawerItem = new PrimaryDrawerItem().withName("Settings").withTag("settings").withIcon(GoogleMaterial.Icon.gmd_settings);
ndMenu = new DrawerBuilder()
.withActivity(this)
.withToolbar(tbMain)
.withCloseOnClick(true)
.withFireOnInitialOnClick(true)
.withSelectedItemByPosition(6)
.withDelayDrawerClickEvent(300)
.withDisplayBelowStatusBar(true)
.withTranslucentStatusBar(false)
.withOnDrawerItemClickListener(this)
.addDrawerItems(section, deviceDrawerItem, settingsDrawerItem, sectionDrawerItem, joyType0DrawerItem, joyType1DrawerItem, joyType2DrawerItem, joyType3DrawerItem, joyType4DrawerItem)
.build();
}
示例10: onCreate
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
PrimaryDrawerItem liveItem = new PrimaryDrawerItem().withName(R.string.live)
.withIdentifier(ID_LIVE);
mHistoryItem = new ExpandableDrawerItem().withName(history)
.withSubItems(mHistoryItems)
.withIdentifier(ID_HISTORY);
PrimaryDrawerItem settingItem = new PrimaryDrawerItem().withName(R.string.setting)
.withIdentifier(ID_SETTING);
mDrawer = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.withRootView(R.id.container)
.withActionBarDrawerToggle(true)
.withActionBarDrawerToggleAnimated(true)
.addDrawerItems(liveItem)
.addDrawerItems(mHistoryItem)
.addDrawerItems(new DividerDrawerItem())
.addDrawerItems(settingItem)
.withOnDrawerItemClickListener(this)
.build();
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
player = new GiraffePlayer(this);
playLive();
prepareHistory();
}
示例11: setupDrawer
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
@Override
public void setupDrawer(Me me, Optional<LuckyNumber> luckyNumber) {
TextDrawable icon = getIcon(me);
ProfileDrawerItem profile = getProfileDrawerItem(me, icon);
DrawerBuilder drawerBuilder = new DrawerBuilder()
.withActivity(this)
.addStickyDrawerItems(settingsPresenter.convertToDrawerItem(this::displayFragment))
.withDelayOnDrawerClose(50)
.withOnDrawerNavigationListener(clickedView -> {
onBackPressed();
return true;
})
.withActionBarDrawerToggle(true)
.withActionBarDrawerToggleAnimated(true)
.withToolbar(toolbar)
.withAccountHeader(getDrawerHeader(profile));
StreamSupport.stream(fragmentPresenters)
.sorted(Ordering.natural().onResultOf(MainFragmentPresenter::getOrder))
.map(presenter -> presenter.convertToDrawerItem(p -> displayFragment(presenter)))
.forEach(drawerBuilder::addDrawerItems);
if (luckyNumber.isPresent()) {
drawerBuilder.addDrawerItems(
new DividerDrawerItem(),
getLuckyNumberDrawerItem(luckyNumber.get()));
}
this.drawer = drawerBuilder.build();
}
示例12: onCreate
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Timber.v("onCreate() Called");
// Redirect to Launch activity if we can't inject the Team Component.
TeamComponent teamComponent = ((App) getApplication()).getTeamComponent();
if (teamComponent == null) {
LaunchActivity.launch(this);
finish();
return;
}
teamComponent.inject(this);
setContentView(R.layout.ac_main);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
// Set up the drawer.
drawer = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(final View view, final int position, final IDrawerItem drawerItem) {
return presenter.drawerItemClicked(drawer, position, drawerItem);
}
})
.build();
// Disable pull to refresh.
postsRefreshView.setEnabled(false);
// Connect to the presenter.
presenter.takeView(this, savedInstanceState);
}
示例13: setNavigationDrawer
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
/**
* Method to set Navigation Drawer
* Uses library https://github.com/mikepenz/MaterialDrawer
*/
private void setNavigationDrawer() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ProfileDrawerItem profileDrawerItem;
profileDrawerItem = new ProfileDrawerItem()
.withName("John Davis")
.withEmail("[email protected]")
.withIcon(getResources()
.getDrawable(R.drawable.ic_person_pink_600_48dp));
// Create the AccountHeader
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(LibraryActivity.this)
.addProfiles(profileDrawerItem)
.withHeaderBackground(R.drawable.header)
.withAlternativeProfileHeaderSwitching(false)
.withCurrentProfileHiddenInList(true)
.withResetDrawerOnProfileListClick(false)
.withSelectionFirstLineShown(false)
.withSelectionListEnabledForSingleProfile(true)
.build();
navigationDrawer = new DrawerBuilder()
.withActivity(LibraryActivity.this)
.withAccountHeader(headerResult)
.build();
}
}, 0);
}
示例14: onCreateView
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
// don't look at this layout it's just a listView to show how to handle the keyboard
View view = inflater.inflate(R.layout.fragment_simple_sample, container, false);
result = new DrawerBuilder()
.withActivity(getActivity())
.withRootView((ViewGroup) view.findViewById(R.id.rootView))
.withDisplayBelowStatusBar(false)
.withSavedInstance(savedInstanceState)
.addDrawerItems(
new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1),
new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
new SectionDrawerItem().withName(R.string.drawer_item_section_header),
new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog),
new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false),
new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github),
new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn)
)
.buildForFragment();
TextView textView = (TextView) view.findViewById(R.id.title);
textView.setText(getArguments().getString(KEY_TITLE));
result.getDrawerLayout().setFitsSystemWindows(false);
result.getSlider().setFitsSystemWindows(false);
return view;
}
示例15: onCreate
import com.mikepenz.materialdrawer.DrawerBuilder; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_collapsing_toolbar);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbarLayout.setTitle(getString(R.string.drawer_item_collapsing_toolbar_drawer));
headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withCompactStyle(false)
.withHeaderBackground(R.drawable.header)
.withSavedInstance(savedInstanceState)
.build();
result = new DrawerBuilder()
.withActivity(this)
.withAccountHeader(headerResult)
.withToolbar(toolbar)
.withFullscreen(true)
.addDrawerItems(
new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1),
new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye),
new SectionDrawerItem().withName(R.string.drawer_item_section_header),
new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog),
new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false),
new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github),
new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn)
)
.withSavedInstance(savedInstanceState)
.build();
fillFab();
loadBackdrop();
}