Android appcompact not showing copy action from context action bar for text selection

I am facing a strange problem.
When I use the Android puzzle theme as my default theme and then select text in the webview, the contextual action bar displays correctly.

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

      

enter image description here

But when I use the compact holo app theme, select everything and copy the action.

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

      

enter image description here

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

+3


source to share


1 answer


Because in your menu.xml file you are using the attribute app:showAsAction="ifRoom"

for the non-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 under the 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 under the 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>

      

Also, if you are using Theme.AppCompat.Light

, you should be using ActivityActionBar in your code.

+4


source







All Articles