‘setHasOptionsMenu(Boolean): Unit’ is deprecated. Deprecated in Java

From the Developer documentation, this can be achieved by the following: /** * Using the addMenuProvider() API directly in your Activity **/ class ExampleActivity : ComponentActivity(R.layout.activity_example) { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Add menu items without overriding methods in the Activity addMenuProvider(object : MenuProvider { override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { // … Read more

or (HTML5)

nav is used for groups of internal links (a elements). Generally this means the links should travel to separate pages, or change content in the case of an AJAX page. Expect some sort of content change when clicking on a nav item. menu is used for groups of controls (a, input, button). Generally this means … Read more

How to build unlimited level of menu through PHP and mysql

Here is a “developer-friendly” version of the “one query, no recursion” solution for this problem. SQL: SELECT id, parent_id, title, link, position FROM menu_item ORDER BY parent_id, position; PHP: $html=””; $parent = 0; $parent_stack = array(); // $items contains the results of the SQL query $children = array(); foreach ( $items as $item ) $children[$item[‘parent_id’]][] … Read more

Twitter Bootstrap add active class to li

For Bootstrap 3: var url = window.location; // Will only work if string in href matches with location $(‘ul.nav a[href=”‘+ url +'”]’).parent().addClass(‘active’); // Will also work for relative and absolute hrefs $(‘ul.nav a’).filter(function() { return this.href == url; }).parent().addClass(‘active’); Update For Bootstrap 4: var url = window.location; // Will only work if string in href … Read more

How to get selected value of a dropdown menu in ReactJS

The code in the render method represents the component at any given time. If you do something like this, the user won’t be able to make selections using the form control: <select value=”Radish”> <option value=”Orange”>Orange</option> <option value=”Radish”>Radish</option> <option value=”Cherry”>Cherry</option> </select> So there are two solutions for working with forms controls: Controlled Components Use component state … Read more

How to switch JPanels in a JFrame from within the panel?

Like so : import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; import java.awt.Dimension; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class CardLayoutDemo extends JFrame { public final String YELLOW_PAGE = “yellow page”; public final String RED_PAGE = “red page”; private final CardLayout cLayout; private final JPanel mainPane; boolean isRedPaneVisible; public CardLayoutDemo(){ setTitle(“Card Layout Demo”); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocationRelativeTo(null); mainPane … Read more

Toolbar options menu background color

To change the toolbar options menu color, add this to your toolbar element app:popupTheme=”@style/MyDarkToolbarStyle” Then in your styles.xml define the popup menu style <style name=”MyDarkToolbarStyle” parent=”ThemeOverlay.AppCompat.Light”> <item name=”android:colorBackground”>@color/mtrl_white_100</item> <item name=”android:textColor”>@color/mtrl_light_blue_900</item> </style> Note that you need to use colorBackground not background. The latter would be applied to everything (the menu itself and each menu item), the … Read more