Android custom dropdown/popup menu

Update: To create a popup menu in android with Kotlin refer my answer here. To create a popup menu in android with Java: Create a layout file activity_main.xml under res/layout directory which contains only one button. Filename: activity_main.xml <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” android:paddingBottom=”@dimen/activity_vertical_margin” android:paddingLeft=”@dimen/activity_horizontal_margin” android:paddingRight=”@dimen/activity_horizontal_margin” android:paddingTop=”@dimen/activity_vertical_margin” tools:context=”.MainActivity” > <Button android:id=”@+id/button1″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentLeft=”true” android:layout_alignParentTop=”true” … Read more

Giving JMenuItem’s name to it’s ActionListener

another way as implementing inner ActionListener (with setActionCommand(String actionCommand)) for whole JMenu is wrote java.swing.Action for each of JMenuItem or implements EventHandler (seems like as valid for all Listeners that I tried) example about JButtons and with implemented ActionListener and EventHandler (both Listeners firing events) EDIT: EventHandler os too hacky, because in Swing aren’t another … Read more

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

jQuery add class .active on menu

Click here for a solution in jsFiddle What you need is you need to get window.location.pathname as mentioned and then create regexp from it and test it against navigation hrefs. $(function(){ var url = window.location.pathname, urlRegExp = new RegExp(url.replace(/\/$/,”) + “$”); // create regexp to match current url pathname and remove trailing slash if present … Read more

Changing Locale within the app itself

Through the original question is not exactly about the locale itself all other locale related questions are referencing to this one. That’s why I wanted to clarify the issue here. I used this question as a starting point for my own locale switching code and found out that the method is not exactly correct. It … Read more