I have a drawer layout used as the navigation tab I have everything installed, but now I have a small Button which will open it and close it (actionbars, or something like this). How can I set it as much as possible? (I'm a relative beginner, so I'm not managing it very well)
It needs to have a button in the top left corner (such as the YouTube app) that opens the drawer And toggle off.
Edit: I'm adding my code to the drawer:
The main activity of the public class, actionbrewworks (Private Drawer Late Maider Laureate); Personal list view mDrawerList; / *** / Public Navigator List Adapter NavDrawerListAdapter; Piece piece; @ Override Protected Zero (InstanceState saved from bundle) {classItems = new ArrayList & lt; CategoryItem & gt; (); CategoryItems.populate (); NavDrawerListAdapter = New NavDrawerListAdapter (this, categorization); MDrawerList.addHeaderView (Lyndair, Empty, Wrong); // List Listener Mdrr List. Set-On Item ClickClicklist (New DruiterInstall ClickClicklist); MDrawerLayout = (DrawerLayout) findViewById (R.id.drawer_layout); MDrawerList = (list view) Find VVBID (RID. Left_driver); }}
Among other things, there is a simple adapter (Nevadriarlst adapter) and a simple JavaBin range item. There is also a small function populate () which adds some element to the list. All of those tasks are completely now all I need is to open the toggle button in the top left corner and close the navigation drawer.
public class main activity action breakthrough (private actionbar drawer toggle; @ override protected zero creation Bundle saved instenstate) {super.naught (savedinstenstate); setContentView (R.layout.activity_main); toolbar toolbar = (find toolbar) ViewById (R.id.toolbar_widget); setSupportActionBar; getSupportActionBar () setDisplayHomeAsUpEnabled (Correct). Find Druwer Layout Drawer Layout = (Drawer Layout) VVBIID (Arkaid. Drevr_leaut); toggle = new Actionbar drawer toggle (it Dovr layout, r. String Drevr_open, R. Store Drevr_clos); ToggleksetDrawerIndicatorEnabled (right); DrawerLayoutksetDrawerListener (Toggle);} @ Override public boolean On option istem selected (menu item) {return toggle! = Null & toggle.options from item (item)} super.onOptionsItemSelected (item);} Protected over @OverridePostCreate (bundled saved instenstate) {super. OnPostCreate (SavedInstanceState); if (toggle! = Null) toggle.syncState (); } @ Override converting configuration to public Zero (configuration new config) {super.onConfigurationChanged (newConfig); If Toggle (Toggle! = Null) But the configuration changed (new config); }}
Edit: build.gradle not forget to add context to support the library:
compile 'Com .android Support: support-v4: 22.0.0 'compile' com.android.support:appcompat- v7-22.0.0 '
or all imports:
< Code> Import android.support.v4.widget.DrawerLayout; Import android.support.v7.app.ActionBarActivity; Import android.support.v7.app.ActionBarDrawerToggle; Import android.support.v7.widget.Toolbar; Import android.view.MenuItem; Import android.content.res.configuration;
and the styles.xml should check, parent theme:
& lt; Style name = "AppTheme" parent = "Theme.AppCompat.Light.NoActionBar" & gt;
No comments:
Post a Comment