android - Running ActionBarActivity instead of Fragment on DrawerLayout -
I want to create DrawerLayout for my new Android app. But I need to use the activity on the same activity.
How can I handle this, I have a code like this:
my_activity.java; (A lot of code to the menu list, versus swipe, but I just adds rows of problems I)
switch (status) {case 0: Piece = new Homfrem () ; break; Here is my problem I want to run the activity file on the move but I can not I want to show some activity files case: 0, I've learned something, I tried but I can not do it. In fact I'm a little confused for this piece & amp; Activity Problems Thank you for your help.
First, your activity xml (the one you want to do with navigation drawer using) a & Lt; Android.support.v4.widget.DrawerLayout xmlns: Android = "http://schemas.android.com/apk/res/android" & gt; In its original element and list view (at previous XML hierarchy)
& lt; ListView android: id = "@ + id / left_drawer" Android: layout_width = "240dp" Android: Layout_height = "Match_parent" Android: Layout_gravity = "start" android: background = "@ android: color / background_light" Android: ChoiceMode = " SingleChoice "/>
In your activity, you must have this:
DraftLayout DraftLayout; List view drawer list; Actionbar drawer toggle drawer switch; ... Creates a Protected Zune (Bundle Saved InstantState) {super.onCreate (SavedInstanceState); SetContentView (R.layout.activity_main); Dovr toggle = new Actionbar drawer toggle (it Dovr layout, Ardroveblkaisi_drauvr, R. Stringkupan, R. String. Klose); DrawerLayout.setDrawerListener (drawerToggle); DrawerList.setAdapter (new your adapter type) ()); DrawerList.setOnItemClickListener (New OnItemClickListener) {@Override Public Zero onItemClick (AdapterView & lt; & gt; arg0, see ARG1, integer ARG2, long arg3) {switch (ARG2) {Case 0: Intent L = New Intent (MainActivity. this, FriendActivity.class); startActivity (L); break; case 1: intent J = new intent (MainActivity.this, RequestActivity.class); startActivity (j); break; case 2: intent i = new intent (MainActivity. This, SettingsActivity.class); startActivity (i); break; ...} drawerLayout.closeDrawer (drawerList);}}); Within each "case" statement, you must use intent to initiate an activity and start a new activity. You just want change pieces inside "case" (instead of starting new activities) you should do something like this:.
getSupportFragmentManager () startTransaction () .replace (YOUR_ROOT_VIEW_ID, new fragmenttobeinstantiated ()) // optinal .adobebackstack (faucet) .commit (); See that it helps!
Comments
Post a Comment