Posts

Showing posts with the label Menu

Android: Styling Overflow Menu In Action Bar

Answer : I did it this way: <style name="Theme.yourapp" parent="@style/Theme.AppCompat.Light.DarkActionBar"> <item name="android:actionBarWidgetTheme">@style/Theme.yourapp.Widget</item> </style> <style name="Theme.yourapp.Widget" parent="@style/Theme.AppCompat"> <item name="android:textColor">@android:color/black</item> </style> For simplicity, the android: namespace pertains to anything built into the OS while anything without android: as the namespace would pertain to your application (and the libraries you are using). Most, if not all, support libraries for the ActionBar will try to use the native ActionBar implementation and therefor use the android: namespace attributes in your styles. When the native ActionBar is not available it would use the libraries implementation and the non- android: namespaced attributes. This is why you must specify every attribute w...

Add Selected Attribute To Option In Select Menu With JQuery

Answer : As of jQuery 1.6 "To retrieve and change DOM properties such as the checked, selected, or disabled state of form elements, use the .prop() method." $("#someselect option[value=somevalue]").prop("selected", "selected") Edit: Select Option: $("#someselect option[value=somevalue]").prop("selected", true) Deselect Option: $("#someselect option[value=somevalue]").prop("selected", false) Check out this previous detailled answer on SO: If you really want to maitain HTML output with selected attribute, and not only have jQuery maitaining the right selectedIndex attribute on the select element, you can hack with original settAttr() function: select[0].options[select[0].selectedIndex].setAttribute('selected','selected'); But as soon as you keep using jQuery methods for val() or ':selected', you should'nt get any problem, you could have problem only if you were par...

Android Custom Dropdown/popup Menu

Answer : 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...