3
votes

I faced with the weird issue.
When I use android holo theme as default theme, and then selecting text on webview, the contextual action bar show correctly.

<style name="MyTheme" parent="Theme.AppCompat.Light">   
</style>

enter image description here

But when I use app compact holo theme, the select all and copy action are gone.

<style name="MyTheme" parent="android:Theme.Holo.Light">   
</style>

enter image description here

Where is my problem? My app supports android devices 4.0+

1
If you are using App compact theme then you must use app:showAsAction="always" instead of android:showAsAction="always" for your menu item and add xml schema for that xmlns:app="http://schemas.android.com/apk/res-auto.Piyush
@PiyushGupta well, actually, I don't use any custom option menu or custom CAB, this is the default behavior on web view selection (I mean I don't override onCreateOptionMenu or something like that), test on several samsung devicesR4j

1 Answers

4
votes

Because in your menu.xml file you use atribute app:showAsAction="ifRoom" for not app commpat theme. Please change app:showAsAction="ifRoom" to android:showAsAction="ifRoom" and should work

Example

For this style

<style name="AppTheme" parent="android:Theme.Holo.Light">

works below menu

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      tools:context=".MainActivity">
    <item android:id="@+id/pase"
          android:title="@string/action_settings"
          android:orderInCategory="100"
          android:icon="@drawable/abc_ic_menu_paste_mtrl_am_alpha"
       //look here is a different
          android:showAsAction="ifRoom"/>
    <item android:id="@+id/copy"
          android:title="@string/action_settings"
          android:icon="@drawable/abc_ic_menu_copy_mtrl_am_alpha"
          android:orderInCategory="100"
          android:showAsAction="ifRoom"/>
    <item android:id="@+id/action_settings"
          android:title="@string/action_settings"
          android:orderInCategory="100"
          android:showAsAction="never"/>
</menu>

For this style

<style name="AppTheme" parent="Theme.AppCompat.Light">

works below menu

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      tools:context=".MainActivity">
    <item android:id="@+id/pase"
          android:title="@string/action_settings"
          android:orderInCategory="100"
          android:icon="@drawable/abc_ic_menu_paste_mtrl_am_alpha"
       //look here is a different
          app:showAsAction="ifRoom"/>
    <item android:id="@+id/copy"
          android:title="@string/action_settings"
          android:icon="@drawable/abc_ic_menu_copy_mtrl_am_alpha"
          android:orderInCategory="100"
          app:showAsAction="ifRoom"/>
    <item android:id="@+id/action_settings"
          android:title="@string/action_settings"
          android:orderInCategory="100"
          app:showAsAction="never"/>
</menu>

Additionally if you use Theme.AppCompat.Light you should use ActivityActionBar in your code.