Last active
April 12, 2016 18:51
Revisions
-
pipiscrew renamed this gist
Apr 12, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
pipiscrew revised this gist
Apr 12, 2016 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,7 +66,13 @@ public boolean onOptionsItemSelected(MenuItem item) { private void test() { //is a test! Fragment currentFragment = getFragmentManager().findFragmentById(R.id.frame_container); if (currentFragment instanceof my_fragment) { my_fragment x = (my_fragment) currentFragment; x.pipiscrew_method(); } } //my_fragment.java -
pipiscrew revised this gist
Mar 4, 2016 . No changes.There are no files selected for viewing
-
pipiscrew renamed this gist
Mar 4, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
pipiscrew created this gist
Mar 4, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,97 @@ //source - http://stackoverflow.com/a/22182746/1320686 //the activity_main.xml <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Framelayout to display Fragments --> <FrameLayout android:id="@+id/frame_container" android:layout_width="match_parent" android:layout_height="match_parent" /> <!-- Listview to display slider menu --> <ListView android:id="@+id/list_slidermenu" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:choiceMode="singleChoice" android:divider="#272727" android:dividerHeight="1dp" android:listSelector="@drawable/list_selector" android:background="#303030"/> </android.support.v4.widget.DrawerLayout> //menu > main.xml <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_test" android:orderInCategory="100" android:showAsAction="never" android:title="@string/action_test"/> <item android:id="@+id/action_pipiscrew" android:orderInCategory="100" android:showAsAction="never" android:title="@string/pipiscrew"/> </menu> //activity_main.xml @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // toggle nav drawer on selecting action bar app icon/title if (mDrawerToggle.onOptionsItemSelected(item)) { return true; } // Handle action bar actions click switch (item.getItemId()) { case R.id.action_test: test(); return true; default: return super.onOptionsItemSelected(item); } } private void test() { //is a test! } //my_fragment.java @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //Report that this fragment would like to participate in populating the options menu by receiving a call - http://developer.android.com/reference/android/app/Fragment.html setHasOptionsMenu(true); } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar actions click switch (item.getItemId()) { case R.id.action_pipiscrew: pipiscrew_method(); return true; default: return super.onOptionsItemSelected(item); } } private void pipiscrew_method() { //is a pipiscrew_method! }