Comments (11)
try to make setNavigationItemSelectedListener in MyMenuFragment$onCreateView.
@OverRide
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_menu, container,
false);
ivMenuUserProfilePhoto = (ImageView) view.findViewById(R.id.ivMenuUserProfilePhoto);
NavigationView vNavigation = (NavigationView) view.findViewById(R.id.vNavigation);
vNavigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@OverRide
public boolean onNavigationItemSelected(MenuItem menuItem) {
return false;
}
}) ;
setupHeader();
return setupReveal(view) ;
}
from flowingdrawer.
Thanks For Your Solution,
How can i call another fragment after use
" public boolean onNavigationItemSelected(MenuItem menuItem) {
return false;
} "; ?
i want to open another fragment after i chose drawer_menu.
from flowingdrawer.
the same question with @rhyodhan
from flowingdrawer.
the same question
how to set onnavigationitemselected listner in Activity that use mymenuFragment?
from flowingdrawer.
@vutiendung have u been able to solve it ??
from flowingdrawer.
@alafandiomar hi yes i was able to solve this problem.i declare an object of NavigationView in the MyMenuFragment and in the Main Activity i have declare a NavigationView.OnNavigationItemSelectedListener object that get the item clicked.
at the end i call mMenuFragment.vNavigation.setNavigationItemSelectedListener(navlistner); on toolbar onclick listener.i sent my file for better undrestanding
sorry for delay and bad english
MyMenuFragment.txt
MainActivity.txt
from flowingdrawer.
yes thank u very much i solved it too but by using fragments and interfaces .... if u want fragments instead of activities tell and ill send it to u :D @moh586 thanks
from flowingdrawer.
@alafandiomar could you please send me your solution using fragments and interfaces thanks
from flowingdrawer.
@AhmedDonkl sure thing when i get home :D
from flowingdrawer.
how to make left drawer items clickable .......
from flowingdrawer.
@moh586 : I would like to suggest a better way for the implementation of OnNavigationItemSelectedListener.
public class MyMenuFragment extends MenuFragment {
private ImageView ivMenuUserProfilePhoto;
public NavigationView navigationView;
private LeftDrawerLayout mLeftDrawerLayout;
AmitCallbackWhenDrawerOpens amitCallbackWhenDrawerOpens;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
amitCallbackWhenDrawerOpens = (AmitCallbackWhenDrawerOpens) context;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_menu, container,
false);
View view1 = inflater.inflate(R.layout.activity_main, container,
false);
mLeftDrawerLayout = (LeftDrawerLayout) view1.findViewById(R.id.id_drawerlayout);
navigationView = (NavigationView) view.findViewById(R.id.vNavigation);
//View navHeader = navigationView.getHeaderView(0); using when we are using support library greater than 23.0.0
return setupReveal(view) ;
}
public void onOpenMenu(){
if (amitCallbackWhenDrawerOpens!= null)
amitCallbackWhenDrawerOpens.drawerIsOpen();
Toast.makeText(getActivity(),"onOpenMenu",Toast.LENGTH_SHORT).show();
}
public void onCloseMenu(){
Toast.makeText(getActivity(),"onCloseMenu",Toast.LENGTH_SHORT).show();
}
public interface AmitCallbackWhenDrawerOpens {
void drawerIsOpen();
}
}
public class MainActivity extends AppCompatActivity implements MyMenuFragment.AmitCallbackWhenDrawerOpens{
@OverRide
public void drawerIsOpen() {
mMenuFragment.navigationView.setNavigationItemSelectedListener(navlistner);
}
}
Benefits :
This enables the OnNavigationItemSelected even if someone slides the drawer
from flowingdrawer.
Related Issues (20)
- Show/Hide via code HOT 1
- What kind of methods to use?
- The RTL HOT 2
- How to add items in FlowingDrawer dynamically?
- issue when changing locale HOT 1
- Android P devices HOT 6
- java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed HOT 5
- δΎ§ζ»ι΄ε½±
- Failed to run on Android P HOT 1
- code is clean but app crash when running HOT 1
- java.lang.OutOfMemoryError: com.mxn.soul.flowingdrawer_core.BuildLayerFrameLayout.dispatchDraw
- App crash HOT 3
- header divider not showing on right most part, on flowing view
- header divider not showing on right most part, on flowing view HOT 1
- Invalid Region.Op - only INTERSECT and DIFFERENCE HOT 2
- how use custom attributes, edMenuBackground?
- This should be in MIT Licensed in Anroid
- FlowinMenuLayout overlaped with NavigationBar
- Swipe drawer
- FlowingDrawer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flowingdrawer.