Add Active Navigation Class Based on URL

The reason this isn’t working is because the javascript is executing, then the page is reloading which nullifies the ‘active’ class. What you probably want to do is something like: $(function(){ var current = location.pathname; $(‘#nav li a’).each(function(){ var $this = $(this); // if the current path is like this link, make it active if($this.attr(‘href’).indexOf(current) … Read more

Android adding a submenu to a menuItem, where is addSubMenu()?

Sometimes Android weirdness is really amazing (and amusing..). I solved it this way: a) Define in XML a submenu placeholder like this: <item android:visible=”true” android:id=”@+id/m_area” android:titleCondensed=”Areas” android:title=”Areas” android:icon=”@drawable/restaur” android:enabled=”true”> <menu> <item android:id=”@+id/item1″ android:title=”Placeholder”></item> </menu> </item> b) Get sub menu item in OnCreateOptionsMenu, clear it and add my submenu items, like this: public boolean onCreateOptionsMenu(Menu menu) … Read more

Android Change Navigation Drawer Menu Items Text programmatically

You can change the title of Navigation Menu Item programmatically by adding following lines in MainActivity.java file. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); … //other stuff here … NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); // get menu from navigationView Menu menu = navigationView.getMenu(); // find MenuItem you want to change MenuItem nav_camara = menu.findItem(R.id.nav_camara); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)